From 0cc6f959fc8607c4c3d4d87aab364beb9acfc9c4 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 24 May 2022 21:19:15 +0200 Subject: [PATCH] Option to mark all chat reactions as read --- qml/components/ChatListViewItem.qml | 2 ++ qml/pages/ChatPage.qml | 1 + src/tdlibwrapper.cpp | 9 +++++++++ src/tdlibwrapper.h | 1 + 4 files changed, 13 insertions(+) diff --git a/qml/components/ChatListViewItem.qml b/qml/components/ChatListViewItem.qml index f893445..b24fdc0 100644 --- a/qml/components/ChatListViewItem.qml +++ b/qml/components/ChatListViewItem.qml @@ -51,6 +51,8 @@ PhotoTextsListItem { visible: unread_count > 0 onClicked: { tdLibWrapper.viewMessage(chat_id, display.last_message.id, true); + tdLibWrapper.readAllChatMentions(chat_id); + tdLibWrapper.readAllChatReactions(chat_id); tdLibWrapper.toggleChatIsMarkedAsUnread(chat_id, false); } text: qsTr("Mark all messages as read") diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 072103a..51d071f 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -716,6 +716,7 @@ Page { } if (chatInformation.unread_count === 0) { tdLibWrapper.readAllChatMentions(chatInformation.id); + tdLibWrapper.readAllChatReactions(chatInformation.id); } } } diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 974819a..86da4b9 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1113,6 +1113,15 @@ void TDLibWrapper::readAllChatMentions(qlonglong chatId) this->sendRequest(requestObject); } +void TDLibWrapper::readAllChatReactions(qlonglong chatId) +{ + LOG("Read all chat reactions" << chatId); + QVariantMap requestObject; + requestObject.insert(_TYPE, "readAllChatReactions"); + requestObject.insert(CHAT_ID, chatId); + this->sendRequest(requestObject); +} + void TDLibWrapper::toggleChatIsMarkedAsUnread(qlonglong chatId, bool isMarkedAsUnread) { LOG("Toggle chat is marked as unread" << chatId << isMarkedAsUnread); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 5545318..c31962a 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -217,6 +217,7 @@ public: Q_INVOKABLE void searchChatMessages(qlonglong chatId, const QString &query, qlonglong fromMessageId = 0); Q_INVOKABLE void searchPublicChats(const QString &query); Q_INVOKABLE void readAllChatMentions(qlonglong chatId); + Q_INVOKABLE void readAllChatReactions(qlonglong chatId); Q_INVOKABLE void toggleChatIsMarkedAsUnread(qlonglong chatId, bool isMarkedAsUnread); Q_INVOKABLE void toggleChatIsPinned(qlonglong chatId, bool isPinned); Q_INVOKABLE void setChatDraftMessage(qlonglong chatId, qlonglong threadId, qlonglong replyToMessageId, const QString &draft);