mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Fix conversation lists
This commit is contained in:
parent
136db55703
commit
6dab962349
@ -36,7 +36,7 @@ const ConversationsInterface = {
|
|||||||
var params = {}; //No params required now
|
var params = {}; //No params required now
|
||||||
|
|
||||||
//Perform the API request
|
//Perform the API request
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(results){
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, (results) => {
|
||||||
|
|
||||||
//Check for error
|
//Check for error
|
||||||
if(results.error){
|
if(results.error){
|
||||||
@ -50,7 +50,7 @@ const ConversationsInterface = {
|
|||||||
//Process the list
|
//Process the list
|
||||||
var conversationsList = {};
|
var conversationsList = {};
|
||||||
for(i in results){
|
for(i in results){
|
||||||
conversationsList["conversation-"+results[i].ID] = results[i];
|
conversationsList["conversation-"+results[i].id] = results[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save the list in the cache
|
//Save the list in the cache
|
||||||
@ -61,9 +61,6 @@ const ConversationsInterface = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Success
|
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,7 +212,7 @@ const ConversationsList = {
|
|||||||
/**
|
/**
|
||||||
* Show a conversation entry
|
* Show a conversation entry
|
||||||
*
|
*
|
||||||
* @param {Object} conversationInfos Informations about the conversation
|
* @param {Conversation} conversationInfos Informations about the conversation
|
||||||
* @param {HTMLElement} entryTarget The target for the entry
|
* @param {HTMLElement} entryTarget The target for the entry
|
||||||
* @param {Object} listBox HTML elements about the listBox
|
* @param {Object} listBox HTML elements about the listBox
|
||||||
* @return {Boolean} True for a success
|
* @return {Boolean} True for a success
|
||||||
@ -242,7 +242,7 @@ const ConversationsList = {
|
|||||||
|
|
||||||
//Calculate last conversation activity
|
//Calculate last conversation activity
|
||||||
var currentTime = ComunicWeb.common.date.time();
|
var currentTime = ComunicWeb.common.date.time();
|
||||||
lastActivityValueElem.innerHTML = " "+ComunicWeb.common.date.diffToStr(currentTime - conversationInfos.last_active);
|
lastActivityValueElem.innerHTML = " "+ComunicWeb.common.date.diffToStr(currentTime - conversationInfos.last_activity);
|
||||||
|
|
||||||
|
|
||||||
//Create the conversation name element
|
//Create the conversation name element
|
||||||
@ -269,7 +269,7 @@ const ConversationsList = {
|
|||||||
|
|
||||||
//Specify value
|
//Specify value
|
||||||
var membersNumberValueElem = createElem("span", membersNumberSmallElem);
|
var membersNumberValueElem = createElem("span", membersNumberSmallElem);
|
||||||
membersNumberValueElem.innerHTML = (conversationInfos.members.length === 1 ? "1 member" : conversationInfos.members.length + " members");
|
membersNumberValueElem.innerHTML = (conversationInfos.members.length === 1 ? tr("1 member") : conversationInfos.members.length + " members");
|
||||||
|
|
||||||
//Success
|
//Success
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* @author Pierre HUBERT
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ComunicWeb.pages.conversations.listPane = {
|
const ConversationsPageListPane = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save current list
|
* Save current list
|
||||||
@ -52,18 +52,18 @@ ComunicWeb.pages.conversations.listPane = {
|
|||||||
//Check if box body is still connected
|
//Check if box body is still connected
|
||||||
if(!boxBody.isConnected){
|
if(!boxBody.isConnected){
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
ComunicWeb.pages.conversations.listPane._curr_list = null;
|
ConversationsPageListPane._curr_list = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load the list of conversations
|
//Load the list of conversations
|
||||||
ComunicWeb.pages.conversations.listPane.refresh_list(boxBody);
|
ConversationsPageListPane.refresh_list(boxBody);
|
||||||
|
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
//Force load the list of conversations
|
//Force load the list of conversations
|
||||||
ComunicWeb.pages.conversations.listPane._curr_list = null;
|
ConversationsPageListPane._curr_list = null;
|
||||||
ComunicWeb.pages.conversations.listPane.refresh_list(boxBody);
|
ConversationsPageListPane.refresh_list(boxBody);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ ComunicWeb.pages.conversations.listPane = {
|
|||||||
|
|
||||||
|
|
||||||
//Perform a request over the interface
|
//Perform a request over the interface
|
||||||
ComunicWeb.components.conversations.interface.getList(function(result){
|
ConversationsInterface.getList((result) => {
|
||||||
|
|
||||||
//Check for errors
|
//Check for errors
|
||||||
if(result.error){
|
if(result.error){
|
||||||
@ -101,14 +101,14 @@ ComunicWeb.pages.conversations.listPane = {
|
|||||||
loadingMsg.remove();
|
loadingMsg.remove();
|
||||||
|
|
||||||
//Check if it is required to apply new list
|
//Check if it is required to apply new list
|
||||||
if(JSON.stringify(ComunicWeb.pages.conversations.listPane._curr_list) == JSON.stringify(result))
|
if(JSON.stringify(ConversationsPageListPane._curr_list) == JSON.stringify(result))
|
||||||
return;
|
return;
|
||||||
ComunicWeb.pages.conversations.listPane._curr_list = result;
|
ConversationsPageListPane._curr_list = result;
|
||||||
|
|
||||||
emptyElem(target); //Remove any previously shown list
|
emptyElem(target); //Remove any previously shown list
|
||||||
|
|
||||||
//Display the list of conversations
|
//Display the list of conversations
|
||||||
ComunicWeb.pages.conversations.listPane._display_list(target, result);
|
ConversationsPageListPane._display_list(target, result);
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -150,7 +150,7 @@ ComunicWeb.pages.conversations.listPane = {
|
|||||||
* Display a single conversation entry
|
* Display a single conversation entry
|
||||||
*
|
*
|
||||||
* @param {HTMLElement} target The target for the conversation
|
* @param {HTMLElement} target The target for the conversation
|
||||||
* @param {Object} info Information about the conversation to display
|
* @param {Conversation} info Information about the conversation to display
|
||||||
*/
|
*/
|
||||||
_display_entry: function(target, info) {
|
_display_entry: function(target, info) {
|
||||||
|
|
||||||
@ -168,13 +168,13 @@ ComunicWeb.pages.conversations.listPane = {
|
|||||||
convLink.addEventListener("click", function(e){
|
convLink.addEventListener("click", function(e){
|
||||||
|
|
||||||
//Force conversation list refresh
|
//Force conversation list refresh
|
||||||
ComunicWeb.pages.conversations.listPane._curr_list = {};
|
ConversationsPageListPane._curr_list = {};
|
||||||
|
|
||||||
//Make the choice visible
|
//Make the choice visible
|
||||||
convLink.className += " selected";
|
convLink.className += " selected";
|
||||||
|
|
||||||
//Open the conversation
|
//Open the conversation
|
||||||
openPage("conversations/"+info.ID)
|
openPage("conversations/"+info.id)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ ComunicWeb.pages.conversations.listPane = {
|
|||||||
createElem2({
|
createElem2({
|
||||||
appendTo: lastActivityContainer,
|
appendTo: lastActivityContainer,
|
||||||
type: "span",
|
type: "span",
|
||||||
innerHTML: ComunicWeb.common.date.timeDiffToStr(info.last_active)
|
innerHTML: ComunicWeb.common.date.timeDiffToStr(info.last_activity)
|
||||||
});
|
});
|
||||||
|
|
||||||
//Add conversation name
|
//Add conversation name
|
||||||
@ -199,7 +199,7 @@ ComunicWeb.pages.conversations.listPane = {
|
|||||||
type: info.saw_last_message ? "span" : "strong",
|
type: info.saw_last_message ? "span" : "strong",
|
||||||
innerHTML: "Loading..."
|
innerHTML: "Loading..."
|
||||||
});
|
});
|
||||||
ComunicWeb.components.conversations.utils.getName(info, function(name){
|
ConversationsUtils.getName(info, function(name){
|
||||||
conversationName.innerHTML = name;
|
conversationName.innerHTML = name;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ ComunicWeb.pages.conversations.listPane = {
|
|||||||
createElem2({
|
createElem2({
|
||||||
appendTo: membersNumberContainerSmall,
|
appendTo: membersNumberContainerSmall,
|
||||||
type: "span",
|
type: "span",
|
||||||
innerHTML: (info.members.length === 1 ? "1 member" : info.members.length + " members")
|
innerHTML: (info.members.length === 1 ? tr("1 member") : tr("%1% members", {"1": info.members.length}))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ ComunicWeb.pages.conversations.main = {
|
|||||||
|
|
||||||
// Otherwise display the list of conversations
|
// Otherwise display the list of conversations
|
||||||
else {
|
else {
|
||||||
ComunicWeb.pages.conversations.listPane.display(container);
|
ConversationsPageListPane.display(container);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user