summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nassabain <marco.nassabain@hotmail.com>2021-03-14 21:58:16 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 23:17:31 +0200
commitc14fa3eaf62a554e2626da8e93f31ea3ea23b83f (patch)
tree340a339691d9cabdba6345483d6674c80e0006b7
parenta86f78a0a7d034f6b5c19ddfaee2a462c48837d2 (diff)
💡 ShareController: add comments to new fcts
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
-rw-r--r--js/controller/ShareController.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/js/controller/ShareController.js b/js/controller/ShareController.js
index 23b8c525e..a60ea7ed3 100644
--- a/js/controller/ShareController.js
+++ b/js/controller/ShareController.js
@@ -45,6 +45,13 @@ app.controller('ShareController', function (ShareResource, Loading) {
/** Dictionary mapping articles to users they're shared with */
this.usersSharedArticles = [];
+ /**
+ * Test whether an item is shared with a user
+ *
+ * @param itemId ID of the item being shared
+ * @param userId User ID of the recipient
+ * @returns boolean
+ */
this.itemIsSharedWithUser = function(itemId, userId) {
let item = this.usersSharedArticles.find(i => i.id === itemId);
if (!item) {
@@ -57,6 +64,13 @@ app.controller('ShareController', function (ShareResource, Loading) {
return true;
};
+ /**
+ * Inserts an item share action into the dictionary
+ *
+ * @param itemId ID of the item being shared
+ * @param userId User ID of the recipient
+ * @param status boolean indicating if the share was successful
+ */
this.addItemShareWithUser = function(itemId, userId, status) {
let item = this.usersSharedArticles.find(i => i.id === itemId);
if (!item) {
@@ -102,10 +116,24 @@ app.controller('ShareController', function (ShareResource, Loading) {
});
};
+ /**
+ * Indicates whether the share action is in progress
+ *
+ * @param userId User ID of the recipient
+ * @returns boolean
+ */
this.isLoading = function(userId) {
return Loading.isLoading(userId);
};
+ /**
+ * Indicates whether the share actions matches the given status
+ *
+ * @param itemId ID of the item being shared
+ * @param userId User ID of the recipient
+ * @param status true (successful) / false (failed)
+ * @returns boolean
+ */
this.isStatus = function(itemId, userId, status) {
let item = this.usersSharedArticles.find(i => i.id === itemId);
if (!item) {