summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nassabain <marco.nassabain@hotmail.com>2021-03-17 21:24:08 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 23:17:31 +0200
commit0f6a0d790205580e14c11e19d0100ed3c400c89d (patch)
tree3625934d1716d0e8b8f8c01e18bcc9371d390c6d
parentffa476190f90bdc449f1dcc016836ba1a0bd5b38 (diff)
🐛 Share dropdown: only show results of most recent search
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
-rw-r--r--js/controller/ShareController.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/js/controller/ShareController.js b/js/controller/ShareController.js
index e1255e92a..7c1b1a649 100644
--- a/js/controller/ShareController.js
+++ b/js/controller/ShareController.js
@@ -15,23 +15,29 @@ app.controller('ShareController', function (ShareResource, Loading) {
/** Array containing users to share an item with */
this.userList = [];
+ /** Value used to check if the received response is the most recent one */
+ this.searchQuery = '';
+
/**
* @param search Username search query
*
* Retrieve users matching search query using OC
*/
this.searchUsers = function(search) {
- Loading.setLoading('user', true);
if (!search || search === '') {
this.userList = [];
- Loading.setLoading('user', false);
return;
}
+ Loading.setLoading('user', true);
+ this.searchQuery = search;
+
var response = ShareResource.getUsers(search);
response.then((response) => {
- this.userList = response.ocs.data.users;
- Loading.setLoading('user', false);
+ if (this.searchQuery === search) {
+ this.userList = response.ocs.data.users;
+ Loading.setLoading('user', false);
+ }
});
// TODO: catch error
};