diff options
-rw-r--r-- | js/controller/ShareController.js | 16 | ||||
-rw-r--r-- | 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 @@ </form> <div style="margin-left: 2em; font-size: 0.85em;" - ng-if="!(Share.userList.length > 0) && nameQuery && !App.loading.isLoading('user')"> + ng-if="Share.userList.length === 0 && nameQuery && !App.loading.isLoading('user') && !Share.searchUsersFailed"> <?php p($l->t('No users found')) ?> </div> + <div style="margin-left: 2em; font-size: 0.85em;" + ng-if="Share.userList.length === 0 && Share.searchUsersFailed"> + <?php p($l->t('Error while searching for users')) ?> + </div> <a ng-repeat="user in Share.userList" class="icon-category-installed pr-3" |