summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nassabain <marco.nassabain@hotmail.com>2021-03-17 21:45:19 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 23:17:31 +0200
commit299c3428e1769710467e19fa73173625088e177b (patch)
tree0a7661e7170332a649d60a32e547f48b4fe2e5bd
parent0f6a0d790205580e14c11e19d0100ed3c400c89d (diff)
✨ Share dropdown: catch sharee api error, show msg
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
-rw-r--r--js/controller/ShareController.js16
-rw-r--r--templates/part.content.php6
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"