From c14fa3eaf62a554e2626da8e93f31ea3ea23b83f Mon Sep 17 00:00:00 2001 From: Marco Nassabain Date: Sun, 14 Mar 2021 21:58:16 +0100 Subject: =?UTF-8?q?=F0=9F=92=A1=20ShareController:=20add=20comments=20to?= =?UTF-8?q?=20new=20fcts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marco Nassabain --- js/controller/ShareController.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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) { -- cgit v1.2.3