summaryrefslogtreecommitdiffstats
path: root/js/controller/ShareController.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controller/ShareController.js')
-rw-r--r--js/controller/ShareController.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/js/controller/ShareController.js b/js/controller/ShareController.js
index 2977dc2c2..57722f416 100644
--- a/js/controller/ShareController.js
+++ b/js/controller/ShareController.js
@@ -25,7 +25,17 @@ app.controller('ShareController', function (ShareResource) {
});
};
+ // Dict <itemId, List<Int>(user_id)>: Local mapping b/w users & articles: [Article 1 : <Jimmy, Aurelien, ...>, Article 2: <...>]
+ this.usersSharedArticles = {};
+
this.shareItem = function(itemId, userId) {
+ if (this.usersSharedArticles[itemId] && this.usersSharedArticles[itemId].includes(userId)) {return ; }
+
+ // quick initialization (instead of if (...) : [])
+ this.usersSharedArticles[itemId] = this.usersSharedArticles[itemId] ? this.usersSharedArticles[itemId] : [];
+
+ this.usersSharedArticles[itemId].push(userId);
+
var response = ShareResource.shareItem(itemId, userId);
response.then((result) => {
return result;