diff options
author | Marco Nassabain <marco.nassabain@hotmail.com> | 2021-03-17 21:45:19 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-04-08 23:17:31 +0200 |
commit | 299c3428e1769710467e19fa73173625088e177b (patch) | |
tree | 0a7661e7170332a649d60a32e547f48b4fe2e5bd /js | |
parent | 0f6a0d790205580e14c11e19d0100ed3c400c89d (diff) |
✨ Share dropdown: catch sharee api error, show msg
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
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 */ |