From ea8d03bc10d7f1cf203e49c52841e1408398b7e5 Mon Sep 17 00:00:00 2001 From: Angela Mazzurco Date: Mon, 12 Jun 2017 15:44:07 +0200 Subject: [PATCH] Change how do you put chat tittle saving chat name into variable on cache GXS info --- retroshare-qml-app/src/ChatCache.qml | 10 ++++++++-- retroshare-qml-app/src/ChatView.qml | 10 ++++++++-- retroshare-qml-app/src/Contacts.qml | 2 +- retroshare-qml-app/src/GxsIdentityDelegate.qml | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/retroshare-qml-app/src/ChatCache.qml b/retroshare-qml-app/src/ChatCache.qml index 478472516..fb2518cd5 100644 --- a/retroshare-qml-app/src/ChatCache.qml +++ b/retroshare-qml-app/src/ChatCache.qml @@ -51,7 +51,7 @@ QtObject { } function setRemoteGXS (chatId, remoteGXS){ - if (!lastMessageList[chatId]) { + if (!lastMessageList[chatId]) { lastMessageList[chatId] = {} console.log("Last message cache created!") } @@ -66,13 +66,19 @@ QtObject { function getChatIdFromGxs (gxs){ for (var key in lastMessageList) { - if ( lastMessageList[key].remoteGXS === gxs ) { + if ( lastMessageList[key].remoteGXS && + lastMessageList[key].remoteGXS.gxs === gxs ) { return key } } return "" } + function getGxsFromChatId (chatId){ + if (lastMessageList[chatId]) return lastMessageList[chatId].remoteGXS + return undefined + } + function getChatLastMessage (chatId){ if (lastMessageList[chatId]) { return lastMessageList[chatId].lastMessage diff --git a/retroshare-qml-app/src/ChatView.qml b/retroshare-qml-app/src/ChatView.qml index c91b13c14..4f0ea0fde 100644 --- a/retroshare-qml-app/src/ChatView.qml +++ b/retroshare-qml-app/src/ChatView.qml @@ -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() JSONListModel @@ -256,6 +261,7 @@ Item } ] } - } + + } diff --git a/retroshare-qml-app/src/Contacts.qml b/retroshare-qml-app/src/Contacts.qml index 93b43556b..a445ebe72 100644 --- a/retroshare-qml-app/src/Contacts.qml +++ b/retroshare-qml-app/src/Contacts.qml @@ -103,7 +103,7 @@ Item {'action': 'refreshUnread', 'response': par.response}) json.data.forEach (function (chat){ 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() diff --git a/retroshare-qml-app/src/GxsIdentityDelegate.qml b/retroshare-qml-app/src/GxsIdentityDelegate.qml index 675d4f01b..bff13f858 100644 --- a/retroshare-qml-app/src/GxsIdentityDelegate.qml +++ b/retroshare-qml-app/src/GxsIdentityDelegate.qml @@ -258,7 +258,7 @@ Item } function startDistantChatCB (par){ 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) } }