Implement last message cache when a message is received

This commit is contained in:
Angela Mazzurco 2017-06-03 17:58:53 +02:00
parent 93c6a1a7e8
commit 464c16b825
2 changed files with 8 additions and 0 deletions

View File

@ -27,6 +27,7 @@ Item
property string chatId property string chatId
property int token: 0 property int token: 0
function refreshData() function refreshData()
{ {
console.log("chatView.refreshData()", visible) console.log("chatView.refreshData()", visible)
@ -38,6 +39,8 @@ Item
token = JSON.parse(par.response).statetoken token = JSON.parse(par.response).statetoken
TokensManager.registerToken(token, refreshData) TokensManager.registerToken(token, refreshData)
ChatCache.lastMessageCache.updateLastMessageCache(chatId, chatModel.json)
if(chatListView.visible) if(chatListView.visible)
{ {
chatListView.positionViewAtEnd() chatListView.positionViewAtEnd()

View File

@ -101,6 +101,10 @@ Item
TokensManager.registerToken(json.statetoken, refreshUnread) TokensManager.registerToken(json.statetoken, refreshUnread)
contactsSortWorker.sendMessage( contactsSortWorker.sendMessage(
{'action': 'refreshUnread', 'response': par.response}) {'action': 'refreshUnread', 'response': par.response})
json.data.forEach (function (chat){
console.log("@@@@@@@@@@@@ ",chat.chat_id)
ChatCache.lastMessageCache.updateLastMessageCache(chat.chat_id)
})
} }
function refreshUnread() function refreshUnread()
{ {
@ -187,4 +191,5 @@ Item
property bool defaultIdentityCreated: false property bool defaultIdentityCreated: false
} }
} }