diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/controller/ShareController.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/js/controller/ShareController.js b/js/controller/ShareController.js index 7c1b1a649..43e0a8c05 100644 --- a/js/controller/ShareController.js +++ b/js/controller/ShareController.js @@ -18,12 +18,16 @@ app.controller('ShareController', function (ShareResource, Loading) { /** Value used to check if the received response is the most recent one */ this.searchQuery = ''; + /** True if the most recent request failed */ + this.searchUsersFailed = false; + /** * @param search Username search query * * Retrieve users matching search query using OC */ this.searchUsers = function(search) { + this.searchUsersFailed = false; if (!search || search === '') { this.userList = []; return; @@ -32,14 +36,20 @@ app.controller('ShareController', function (ShareResource, Loading) { Loading.setLoading('user', true); this.searchQuery = search; - var response = ShareResource.getUsers(search); - response.then((response) => { + ShareResource.getUsers(search) + .then((response) => { if (this.searchQuery === search) { this.userList = response.ocs.data.users; Loading.setLoading('user', false); } + }) + .catch(() => { + if (this.searchQuery === search) { + this.userList = []; + this.searchUsersFailed = true; + Loading.setLoading('user', false); + } }); - // TODO: catch error }; /** Dictionary mapping articles to users they're shared with */ |