summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nassabain <marco.nassabain@hotmail.com>2021-03-14 21:41:57 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 23:17:31 +0200
commit3d9027a914fd132ef2344a0bf07fd35e07aff283 (patch)
treea10fa93ec1d3b43d8d467bc491c5efa78572b617
parent3a02101e668d6bc1a05d6c6b35708e97d22a104f (diff)
✨ ShareController: catch share error & display ❌
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
-rw-r--r--js/controller/ShareController.js12
-rw-r--r--templates/part.content.php2
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>