mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Created conversation cache
This commit is contained in:
parent
5ccb548e37
commit
89199a8b05
@ -6,6 +6,11 @@
|
|||||||
|
|
||||||
ComunicWeb.components.conversations.chatWindows = {
|
ComunicWeb.components.conversations.chatWindows = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var {Object} __conversationsCache Chat windows cache
|
||||||
|
*/
|
||||||
|
__conversationsCache: {},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a new conversation window
|
* Open a new conversation window
|
||||||
*
|
*
|
||||||
@ -68,6 +73,9 @@ ComunicWeb.components.conversations.chatWindows = {
|
|||||||
infos: informations
|
infos: informations
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Save conversation informations in the cache
|
||||||
|
ComunicWeb.components.conversations.chatWindows.__conversationsCache["conversation-"+conversationID] = conversationInfos;
|
||||||
|
|
||||||
//Change the name of the conversation
|
//Change the name of the conversation
|
||||||
ComunicWeb.components.conversations.utils.getName(informations, function(conversationName){
|
ComunicWeb.components.conversations.utils.getName(informations, function(conversationName){
|
||||||
ComunicWeb.components.conversations.chatWindows.changeName(conversationName, conversationWindow);
|
ComunicWeb.components.conversations.chatWindows.changeName(conversationName, conversationWindow);
|
||||||
@ -86,6 +94,46 @@ ComunicWeb.components.conversations.chatWindows = {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unload a chat window
|
||||||
|
*
|
||||||
|
* @param {Integer} conversationID The ID of the conversation to unload
|
||||||
|
* @param {Boolean} keepInfos Keep informations about the chat window
|
||||||
|
* @return {Boolean} True for a success
|
||||||
|
*/
|
||||||
|
unload: function(conversationID, keepInfos){
|
||||||
|
|
||||||
|
if(!this.__conversationsCache["conversation-"+conversationID]){
|
||||||
|
ComunicWeb.debug.logMessage("Couldn't unload conversation: " + conversationID +". It seems not to be loaded...");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Log action
|
||||||
|
ComunicWeb.debug.logMessage("Unloading a conversation: " + conversationID);
|
||||||
|
|
||||||
|
//Remove informations if required
|
||||||
|
if(!keepInfos){
|
||||||
|
delete this.__conversationsCache["conversation-"+conversationID];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Success
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unload all chat windows
|
||||||
|
*
|
||||||
|
* @return {Boolean} True for a success
|
||||||
|
*/
|
||||||
|
unloadAll: function(){
|
||||||
|
|
||||||
|
//Clear conversation object
|
||||||
|
clearObject(this.__conversationsCache);
|
||||||
|
|
||||||
|
//Success
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new chat window
|
* Create a new chat window
|
||||||
*
|
*
|
||||||
@ -116,6 +164,9 @@ ComunicWeb.components.conversations.chatWindows = {
|
|||||||
|
|
||||||
//Remove the conversation from opened ones
|
//Remove the conversation from opened ones
|
||||||
ComunicWeb.components.conversations.cachingOpened.remove(infosBox.conversationID);
|
ComunicWeb.components.conversations.cachingOpened.remove(infosBox.conversationID);
|
||||||
|
|
||||||
|
//Unload conversation
|
||||||
|
ComunicWeb.components.conversations.chatWindows.unload(infosBox.conversationID);
|
||||||
}
|
}
|
||||||
|
|
||||||
infosBox.closeButton.onclick = infosBox.closeFunction;
|
infosBox.closeButton.onclick = infosBox.closeFunction;
|
||||||
@ -154,7 +205,7 @@ ComunicWeb.components.conversations.chatWindows = {
|
|||||||
* Change the name of the converation at the top of the windows
|
* Change the name of the converation at the top of the windows
|
||||||
*
|
*
|
||||||
* @param {String} newName The new name for the conversation window
|
* @param {String} newName The new name for the conversation window
|
||||||
* @param {Ojbect} infos INformations about the conversation window
|
* @param {Ojbect} infos Informations about the conversation window
|
||||||
* @return {Boolean} True for a success
|
* @return {Boolean} True for a success
|
||||||
*/
|
*/
|
||||||
changeName: function(newName, infos){
|
changeName: function(newName, infos){
|
||||||
@ -369,9 +420,6 @@ ComunicWeb.components.conversations.chatWindows = {
|
|||||||
//Now, freeze the submit button
|
//Now, freeze the submit button
|
||||||
conversation.settingsForm.createButton.disabled = true;
|
conversation.settingsForm.createButton.disabled = true;
|
||||||
|
|
||||||
//Export conversation ID (to avoid error after)
|
|
||||||
var conversationID = conversation.infos.ID;
|
|
||||||
|
|
||||||
//Peform a request through the interface
|
//Peform a request through the interface
|
||||||
ComunicWeb.components.conversations.interface.updateSettings(newValues, function(result){
|
ComunicWeb.components.conversations.interface.updateSettings(newValues, function(result){
|
||||||
|
|
||||||
@ -383,12 +431,14 @@ ComunicWeb.components.conversations.chatWindows = {
|
|||||||
ComunicWeb.common.notificationSystem.showNotification("An error occured while trying to update conversation settings !", "danger", 4);
|
ComunicWeb.common.notificationSystem.showNotification("An error occured while trying to update conversation settings !", "danger", 4);
|
||||||
|
|
||||||
//Reload the conversation
|
//Reload the conversation
|
||||||
ComunicWeb.components.conversations.chatWindows.load(conversationID, conversation.box);
|
ComunicWeb.components.conversations.chatWindows.unload(conversation.infos.ID, true);
|
||||||
|
ComunicWeb.components.conversations.chatWindows.load(conversation.infos.ID, conversation.box);
|
||||||
console.log("Function callback !!!!!!!!!!!!!!", result);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Success
|
//Success
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Register conversations cache cleaning function
|
||||||
|
ComunicWeb.common.cacheManager.registerCacheCleaner("ComunicWeb.components.conversations.chatWindows.unloadAll");
|
Loading…
Reference in New Issue
Block a user