From 299c3428e1769710467e19fa73173625088e177b Mon Sep 17 00:00:00 2001 From: Marco Nassabain Date: Wed, 17 Mar 2021 21:45:19 +0100 Subject: =?UTF-8?q?=E2=9C=A8=20Share=20dropdown:=20catch=20sharee=20api=20?= =?UTF-8?q?error,=20show=20msg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marco Nassabain --- js/controller/ShareController.js | 16 +++++++++++++--- templates/part.content.php | 6 +++++- 2 files changed, 18 insertions(+), 4 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 */ diff --git a/templates/part.content.php b/templates/part.content.php index 554382fd1..ff288631d 100644 --- a/templates/part.content.php +++ b/templates/part.content.php @@ -136,9 +136,13 @@
+ ng-if="Share.userList.length === 0 && nameQuery && !App.loading.isLoading('user') && !Share.searchUsersFailed"> t('No users found')) ?>
+
+ t('Error while searching for users')) ?> +