aboutsummaryrefslogtreecommitdiffstats
path: root/core/js/sharedialogview.js
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-03-20 13:14:26 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-03-21 04:31:08 +0100
commit6eb5cc54120168351286572b18bd1e07dc3bbc5c (patch)
treee506ff9159d1a88acc509c00eaba8d4ceea49ece /core/js/sharedialogview.js
parent10a4f8e45ee1e3b6a8f2b6c9348271724eb3371b (diff)
downloadnextcloud-server-6eb5cc54120168351286572b18bd1e07dc3bbc5c.tar.gz
nextcloud-server-6eb5cc54120168351286572b18bd1e07dc3bbc5c.zip
Reuse last suggestions if the same parameters are used
When a share is confirmed the suggestions are got to check if there is an exact match. Usually the suggestions were already got with the same parameters in order to fill the autocomplete dropdown, so to avoid a superfluous request now the last suggestions are reused when got again, although only if the same parameters as the last time are used. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'core/js/sharedialogview.js')
-rw-r--r--core/js/sharedialogview.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js
index 0f1d8f39550..96f076c6a47 100644
--- a/core/js/sharedialogview.js
+++ b/core/js/sharedialogview.js
@@ -65,6 +65,9 @@
/** @type {object} **/
shareeListView: undefined,
+ /** @type {object} **/
+ _lastSuggestions: undefined,
+
events: {
'focus .shareWithField': 'onShareWithFieldFocus',
'input .shareWithField': 'onShareWithFieldChanged',
@@ -136,6 +139,13 @@
},
_getSuggestions: function(searchTerm, perPage, model) {
+ if (this._lastSuggestions &&
+ this._lastSuggestions.searchTerm === searchTerm &&
+ this._lastSuggestions.perPage === perPage &&
+ this._lastSuggestions.model === model) {
+ return this._lastSuggestions.promise;
+ }
+
var deferred = $.Deferred();
$.get(
@@ -289,7 +299,14 @@
deferred.reject();
});
- return deferred.promise();
+ this._lastSuggestions = {
+ searchTerm: searchTerm,
+ perPage: perPage,
+ model: model,
+ promise: deferred.promise()
+ };
+
+ return this._lastSuggestions.promise;
},
autocompleteHandler: function (search, response) {