From 3d9027a914fd132ef2344a0bf07fd35e07aff283 Mon Sep 17 00:00:00 2001 From: Marco Nassabain Date: Sun, 14 Mar 2021 21:41:57 +0100 Subject: =?UTF-8?q?=E2=9C=A8=20ShareController:=20catch=20share=20error=20?= =?UTF-8?q?&=20display=20=E2=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marco Nassabain --- js/controller/ShareController.js | 12 ++++++++---- 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 }} + 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)}"> -- cgit v1.2.3