From 1bfac6d0941894677117144519d14f8f3ed455ec Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Thu, 15 Sep 2022 11:57:23 +0200 Subject: [PATCH] Improve loading for tags When opening the tag select and type something the tags are loaded. If you continue to type but the tags are not finally loaded yet (the first xhr request is still running) another xhr request is triggered. This happens for every keystroke. Signed-off-by: Daniel Kesselberg --- core/src/systemtags/systemtagscollection.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/systemtags/systemtagscollection.js b/core/src/systemtags/systemtagscollection.js index 685eb65182a..b123ef30fe4 100644 --- a/core/src/systemtags/systemtagscollection.js +++ b/core/src/systemtags/systemtagscollection.js @@ -69,7 +69,7 @@ fetch: function(options) { var self = this options = options || {} - if (this.fetched || options.force) { + if (this.fetched || this.working || options.force) { // directly call handler if (options.success) { options.success(this, null, options) @@ -79,10 +79,13 @@ return Promise.resolve() } + this.working = true + var success = options.success options = _.extend({}, options) options.success = function() { self.fetched = true + self.working = false if (success) { return success.apply(this, arguments) }