mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Refactor chat cache to get remote GXS from GxsIdentityDelegate.qml instead from ChatView
This commit is contained in:
parent
a0f59959a1
commit
7c4ee55fcf
@ -37,10 +37,6 @@ QtObject {
|
|||||||
console.log("updateLastMessage (chatId, chatModel)")
|
console.log("updateLastMessage (chatId, chatModel)")
|
||||||
var lastMessage = findChatLastMessage (chatModel)
|
var lastMessage = findChatLastMessage (chatModel)
|
||||||
lastMessageList[chatId].lastMessage = lastMessage
|
lastMessageList[chatId].lastMessage = lastMessage
|
||||||
if (!lastMessageList[chatId].remoteGXS) {
|
|
||||||
var firstMessage = findChatFirstMessage (chatModel)
|
|
||||||
setRemoteGXS(chatId, firstMessage.author_id)
|
|
||||||
}
|
|
||||||
lastMessageChanged(chatId, lastMessage)
|
lastMessageChanged(chatId, lastMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +51,10 @@ QtObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setRemoteGXS (chatId, remoteGXS){
|
function setRemoteGXS (chatId, remoteGXS){
|
||||||
|
if (!lastMessageList[chatId]) {
|
||||||
|
lastMessageList[chatId] = {}
|
||||||
|
console.log("Last message cache created!")
|
||||||
|
}
|
||||||
if (lastMessageList[chatId] && !lastMessageList[chatId].remoteGXS){
|
if (lastMessageList[chatId] && !lastMessageList[chatId].remoteGXS){
|
||||||
lastMessageList[chatId].remoteGXS = remoteGXS
|
lastMessageList[chatId].remoteGXS = remoteGXS
|
||||||
return true
|
return true
|
||||||
|
@ -56,7 +56,7 @@ Item
|
|||||||
"remote_gxs_hex": model.gxs_id }
|
"remote_gxs_hex": model.gxs_id }
|
||||||
rsApi.request("/chat/initiate_distant_chat",
|
rsApi.request("/chat/initiate_distant_chat",
|
||||||
JSON.stringify(jsonData),
|
JSON.stringify(jsonData),
|
||||||
contactsView.startChatCallback)
|
startDistantChatCB)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,6 @@ Item
|
|||||||
|
|
||||||
Text
|
Text
|
||||||
{
|
{
|
||||||
// text: (lastMessageData.recv_time)? Date.fromLocaleDateString(locale, lastMessageData.recv_time, "ddd yyyy-MM-dd hh:mm:ss"): "sad"
|
|
||||||
text: setTime()
|
text: setTime()
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
color: "darkslategrey"
|
color: "darkslategrey"
|
||||||
@ -259,5 +258,10 @@ Item
|
|||||||
"qrc:/ContactDetails.qml",
|
"qrc:/ContactDetails.qml",
|
||||||
{md: contactsListView.model.get(index)})
|
{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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user