mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Implemented conversations numbers caching
This commit is contained in:
		@@ -14,12 +14,41 @@ ComunicWeb.components.conversations.cachingOpened = {
 | 
				
			|||||||
	 * @param {Integer} conversationID The ID of the conversation to add
 | 
						 * @param {Integer} conversationID The ID of the conversation to add
 | 
				
			||||||
	 * @return {Boolean} True for a success
 | 
						 * @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
 | 
						 * 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
 | 
						 * Empty the storage
 | 
				
			||||||
@@ -33,7 +62,7 @@ ComunicWeb.components.conversations.cachingOpened = {
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		//Success
 | 
							//Success
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user