mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-03 19:54:14 +00:00 
			
		
		
		
	Added cache system
This commit is contained in:
		
							
								
								
									
										41
									
								
								assets/js/components/conversations/cachingOpened.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								assets/js/components/conversations/cachingOpened.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Opened conversations caching system
 | 
			
		||||
 * 
 | 
			
		||||
 * @author Pierre HUBERT
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
ComunicWeb.components.conversations.cachingOpened = {
 | 
			
		||||
	
 | 
			
		||||
	__varName: "opened-conversations-ids",
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Add a new conversation ID in the list
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param {Integer} conversationID The ID of the conversation to add
 | 
			
		||||
	 * @return {Boolean} True for a success
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get all conversations ID in the list
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @return {Array} An array with all opened conversations ID
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Empty the storage
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @return {Boolean} True for a success
 | 
			
		||||
	 */
 | 
			
		||||
	emptyStorage: function(){
 | 
			
		||||
		
 | 
			
		||||
		//Remove variables for session storage
 | 
			
		||||
		sessionStorage.removeItem(this.__varName);
 | 
			
		||||
		
 | 
			
		||||
		//Success
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Register cache cleaner
 | 
			
		||||
ComunicWeb.common.cacheManager.registerCacheCleaner("ComunicWeb.components.conversations.cachingOpened.emptyStorage", true);
 | 
			
		||||
@@ -182,7 +182,9 @@ ComunicWeb.components.conversations.list = {
 | 
			
		||||
			infos.listBox.rootElem.remove();
 | 
			
		||||
 | 
			
		||||
			//Open the conversation (under construction)
 | 
			
		||||
			console.log("Open conversation ID: " + response.conversationID);
 | 
			
		||||
			ComunicWeb.components.conversations.manager.openConversation({
 | 
			
		||||
				conversationID: response.conversationID
 | 
			
		||||
			});
 | 
			
		||||
		})
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
@@ -255,8 +257,10 @@ ComunicWeb.components.conversations.list = {
 | 
			
		||||
			//Remove conversations list
 | 
			
		||||
			listBox.rootElem.remove();
 | 
			
		||||
 | 
			
		||||
			//Show conversation
 | 
			
		||||
			console.log("Open conversation ID: " + conversationInfos.ID);
 | 
			
		||||
			//Open conversation
 | 
			
		||||
			ComunicWeb.components.conversations.manager.openConversation({
 | 
			
		||||
				conversationID: conversationInfos.ID
 | 
			
		||||
			});
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		//Add conversations last activity
 | 
			
		||||
 
 | 
			
		||||
@@ -79,4 +79,34 @@ ComunicWeb.components.conversations.manager = {
 | 
			
		||||
			ComunicWeb.components.conversations.list.display(this);
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Open a conversation accordingly to specified informations
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param {Object} infos Informations about the conversation to open
 | 
			
		||||
	 * @info {Integer} conversationID The ID of the conversation to open
 | 
			
		||||
	 * @return {Boolean} True or false depending of the success of the operation
 | 
			
		||||
	 */
 | 
			
		||||
	openConversation: function(infos){
 | 
			
		||||
		
 | 
			
		||||
		//We check if a conversation ID was specified or not
 | 
			
		||||
		if(infos.conversationID){
 | 
			
		||||
			ComunicWeb.debug.logMessage("Open a conversation based on its ID");
 | 
			
		||||
			var conversationID = infos.conversationID;
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
			//It is an error
 | 
			
		||||
			ComunicWeb.debug.logMessage("Don't know which conversation to open !");
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		//Log action
 | 
			
		||||
		ComunicWeb.debug.logMessage("Opening conversation " + conversationID);
 | 
			
		||||
 | 
			
		||||
		//Save conversation ID in session storage
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		//Success
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user