diff options
-rw-r--r-- | js/controller/ShareController.js | 12 | ||||
-rw-r--r-- | templates/part.content.php | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/js/controller/ShareController.js b/js/controller/ShareController.js index 673da7319..0bb920eda 100644 --- a/js/controller/ShareController.js +++ b/js/controller/ShareController.js @@ -39,6 +39,7 @@ app.controller('ShareController', function (ShareResource, Loading) { this.userList = response.ocs.data.users; Loading.setLoading('user', false); }); + // TODO: catch error }; /** Dictionary mapping articles to users they're shared with */ @@ -91,10 +92,13 @@ app.controller('ShareController', function (ShareResource, Loading) { Loading.setLoading(userId, true); ShareResource.shareItem(itemId, userId) - .then((result) => { + .then(() => { this.addItemShareWithUser(itemId, userId, true); Loading.setLoading(userId, false); - return result; + }) + .catch(() => { + this.addItemShareWithUser(itemId, userId, false); + Loading.setLoading(userId, false); }); }; @@ -102,7 +106,7 @@ app.controller('ShareController', function (ShareResource, Loading) { return Loading.isLoading(userId); }; - this.isSuccessful = function(itemId, userId) { + this.isStatus = function(itemId, userId, status) { let item = this.usersSharedArticles.find(i => i.id === itemId); if (!item) { return false; @@ -111,7 +115,7 @@ app.controller('ShareController', function (ShareResource, Loading) { if (!user) { return false; } - return user.status; + return user.status === status; }; }); diff --git a/templates/part.content.php b/templates/part.content.php index bde264f2e..71e070d50 100644 --- a/templates/part.content.php +++ b/templates/part.content.php @@ -133,7 +133,7 @@ ng-click="Share.shareItem(item.id, user.value.shareWith)"> {{ user.label }} <span class="right" style="margin-top: 0.9em; margin-right: 1em" - ng-class="{'icon-loading-small': Share.isLoading(user.value.shareWith), 'icon-checkmark': Share.isSuccessful(item.id, user.value.shareWith)}"> + ng-class="{'icon-loading-small': Share.isLoading(user.value.shareWith), 'icon-checkmark': Share.isStatus(item.id, user.value.shareWith, true), 'icon-close': Share.isStatus(item.id, user.value.shareWith, false)}"> </span> </a> |