diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/controller/ShareController.js | 14 |
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 }; |