From 02fa66112ff228926bd55aaf7630dfd73c298109 Mon Sep 17 00:00:00 2001 From: link2xt Date: Tue, 23 Feb 2021 17:35:08 +0300 Subject: Mark chat as noticed when selected --- eventemitter.cpp | 3 +++ eventemitter.h | 1 + qml/ChatlistPage.qml | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/eventemitter.cpp b/eventemitter.cpp index 2265429..b6273bd 100644 --- a/eventemitter.cpp +++ b/eventemitter.cpp @@ -86,6 +86,9 @@ DcAccountsEventEmitter::processEvent(DcEvent *event) event->getData2Int()); std::cout << "Emitted incoming message!" << std::endl; break; + case DC_EVENT_MSGS_NOTICED: + emit messagesNoticed(event->getAccountId(), event->getData1Int()); + break; default: std::cout << "Not processing " << event->getId() << std::endl; } diff --git a/eventemitter.h b/eventemitter.h index 21a8af1..b81778b 100644 --- a/eventemitter.h +++ b/eventemitter.h @@ -52,5 +52,6 @@ signals: void chatModified(uint32_t accountId, int chatId); void incomingMessage(uint32_t accountId, int chatId, int msgId); void messagesChanged(uint32_t accountId, int chatId, int msgId); + void messagesNoticed(uint32_t accountId, int chatId); void incomingEvent(); }; diff --git a/qml/ChatlistPage.qml b/qml/ChatlistPage.qml index 2e1d7fe..5d108c8 100644 --- a/qml/ChatlistPage.qml +++ b/qml/ChatlistPage.qml @@ -18,8 +18,15 @@ Kirigami.Page { updateChatlist(); } + signal messagesNoticed + onMessagesNoticed: { + // Reload chatlist + updateChatlist(); + } + Component.onCompleted: { eventEmitter.onMessagesChanged.connect(messagesChanged) + eventEmitter.onMessagesNoticed.connect(messagesNoticed) updateChatlist() } @@ -81,6 +88,7 @@ Kirigami.Page { onCurrentItemChanged: { var chatId = chatlistModel.get(currentIndex).chatId + chatlistPage.context.marknoticedChat(chatId) console.log("Current index is " + currentIndex) console.log("Selected chat " + chatId) -- cgit v1.2.3-70-g09d2