Refactor chat cache to get remote GXS from GxsIdentityDelegate.qml instead from ChatView

This commit is contained in:
Angela Mazzurco 2017-06-07 15:00:37 +02:00
parent a0f59959a1
commit 7c4ee55fcf
2 changed files with 10 additions and 6 deletions

View File

@ -37,10 +37,6 @@ QtObject {
console.log("updateLastMessage (chatId, chatModel)")
var lastMessage = findChatLastMessage (chatModel)
lastMessageList[chatId].lastMessage = lastMessage
if (!lastMessageList[chatId].remoteGXS) {
var firstMessage = findChatFirstMessage (chatModel)
setRemoteGXS(chatId, firstMessage.author_id)
}
lastMessageChanged(chatId, lastMessage)
}
@ -55,6 +51,10 @@ QtObject {
}
function setRemoteGXS (chatId, remoteGXS){
if (!lastMessageList[chatId]) {
lastMessageList[chatId] = {}
console.log("Last message cache created!")
}
if (lastMessageList[chatId] && !lastMessageList[chatId].remoteGXS){
lastMessageList[chatId].remoteGXS = remoteGXS
return true

View File

@ -56,7 +56,7 @@ Item
"remote_gxs_hex": model.gxs_id }
rsApi.request("/chat/initiate_distant_chat",
JSON.stringify(jsonData),
contactsView.startChatCallback)
startDistantChatCB)
}
}
@ -113,7 +113,6 @@ Item
Text
{
// text: (lastMessageData.recv_time)? Date.fromLocaleDateString(locale, lastMessageData.recv_time, "ddd yyyy-MM-dd hh:mm:ss"): "sad"
text: setTime()
anchors.right: parent.right
color: "darkslategrey"
@ -259,5 +258,10 @@ Item
"qrc:/ContactDetails.qml",
{md: contactsListView.model.get(index)})
}
function startDistantChatCB (par){
var chId = JSON.parse(par.response).data.chat_id
ChatCache.lastMessageCache.setRemoteGXS(chId, model.gxs_id)
contactsView.startChatCallback (par)
}
}