mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Implemented conversations numbers caching
This commit is contained in:
parent
773a003bea
commit
9923b67d2e
@ -14,12 +14,41 @@ ComunicWeb.components.conversations.cachingOpened = {
|
||||
* @param {Integer} conversationID The ID of the conversation to add
|
||||
* @return {Boolean} True for a success
|
||||
*/
|
||||
add: function(conversationID){
|
||||
//Get currently openened conversations
|
||||
var conversations = this.getAll();
|
||||
|
||||
//Add new conversation (if required)
|
||||
if(!conversations.includes(conversationID.toString())){
|
||||
conversations.push(conversationID);
|
||||
|
||||
//Convert into string
|
||||
var conversationsString = conversations.join(";");
|
||||
|
||||
//Save the new values
|
||||
sessionStorage.setItem(this.__varName, conversationsString);
|
||||
}
|
||||
|
||||
//Success
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get all conversations ID in the list
|
||||
*
|
||||
* @return {Array} An array with all opened conversations ID
|
||||
* @return {array} An array with all opened conversations ID
|
||||
*/
|
||||
getAll: function(){
|
||||
|
||||
//Query session storage
|
||||
var results = sessionStorage.getItem(this.__varName);
|
||||
|
||||
if(results === null)
|
||||
return []; //Return an empty array
|
||||
|
||||
//Else parse results
|
||||
return results.split(";");
|
||||
},
|
||||
|
||||
/**
|
||||
* Empty the storage
|
||||
@ -33,7 +62,7 @@ ComunicWeb.components.conversations.cachingOpened = {
|
||||
|
||||
//Success
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user