Change how do you put chat tittle saving chat name into variable on cache GXS info

This commit is contained in:
Angela Mazzurco 2017-06-12 15:44:07 +02:00
parent ba72332ed8
commit ea8d03bc10
4 changed files with 18 additions and 6 deletions

View File

@ -66,13 +66,19 @@ QtObject {
function getChatIdFromGxs (gxs){ function getChatIdFromGxs (gxs){
for (var key in lastMessageList) { for (var key in lastMessageList) {
if ( lastMessageList[key].remoteGXS === gxs ) { if ( lastMessageList[key].remoteGXS &&
lastMessageList[key].remoteGXS.gxs === gxs ) {
return key return key
} }
} }
return "" return ""
} }
function getGxsFromChatId (chatId){
if (lastMessageList[chatId]) return lastMessageList[chatId].remoteGXS
return undefined
}
function getChatLastMessage (chatId){ function getChatLastMessage (chatId){
if (lastMessageList[chatId]) { if (lastMessageList[chatId]) {
return lastMessageList[chatId].lastMessage return lastMessageList[chatId].lastMessage

View File

@ -52,7 +52,12 @@ Item
} ) } )
} }
Component.onCompleted: refreshData() Component.onCompleted: {
refreshData()
toolBar.state = "CHATVIEW"
var gxs = ChatCache.lastMessageCache.getGxsFromChatId(chatView.chatId)
toolBar.titleText = gxs.name
}
onFocusChanged: focus && refreshData() onFocusChanged: focus && refreshData()
JSONListModel JSONListModel
@ -256,6 +261,7 @@ Item
} }
] ]
} }
}
} }
}

View File

@ -103,7 +103,7 @@ Item
{'action': 'refreshUnread', 'response': par.response}) {'action': 'refreshUnread', 'response': par.response})
json.data.forEach (function (chat){ json.data.forEach (function (chat){
ChatCache.lastMessageCache.updateLastMessageCache(chat.chat_id) ChatCache.lastMessageCache.updateLastMessageCache(chat.chat_id)
ChatCache.lastMessageCache.setRemoteGXS (chat.chat_id, chat.remote_author_id) ChatCache.lastMessageCache.setRemoteGXS (chat.chat_id, { gxs: chat.remote_author_id, name: chat.remote_author_name})
}) })
} }
function refreshUnread() function refreshUnread()

View File

@ -258,7 +258,7 @@ Item
} }
function startDistantChatCB (par){ function startDistantChatCB (par){
var chId = JSON.parse(par.response).data.chat_id var chId = JSON.parse(par.response).data.chat_id
ChatCache.lastMessageCache.setRemoteGXS(chId, model.gxs_id) ChatCache.lastMessageCache.setRemoteGXS(chId, { gxs: model.gxs_id, name: model.name})
contactsView.startChatCallback (par) contactsView.startChatCallback (par)
} }
} }