From 3e5ce7c97a332dd629d9d1251a40762af78e342f Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 14 Jun 2017 16:01:16 +0200 Subject: [PATCH] Added remove method --- .../components/conversations/cachingOpened.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/assets/js/components/conversations/cachingOpened.js b/assets/js/components/conversations/cachingOpened.js index a34915b9..64bfcd23 100644 --- a/assets/js/components/conversations/cachingOpened.js +++ b/assets/js/components/conversations/cachingOpened.js @@ -33,6 +33,29 @@ ComunicWeb.components.conversations.cachingOpened = { return true; }, + /** + * Remove a conversation from the list + * + * @param {Integer} conversationID The ID of the conversation to remove + * @return {Boolean} True for a success + */ + remove: function(conversationID){ + + var conversations = this.getAll(); + + if(!conversations.includes(conversationID.toString())){ + return false; //The conversation was not found + } + + //Remove the entry + var entryNumber = conversations.indexOf(conversationID.toString()); + conversations.splice(entryNumber, 1); + + //Save the new values + var conversationsString = conversations.join(";"); + sessionStorage.setItem(this.__varName, conversationsString); + }, + /** * Get all conversations ID in the list *