implement "mark all messages as read" MenuItem

contributes to #70 (doesn't mark anything as unread, though, and does not use toggleChatIsMarkedAsUnread at all)
This commit is contained in:
John Gibbon 2020-10-19 15:30:03 +02:00
parent 214a6c780c
commit 6970dc3625
13 changed files with 49 additions and 5 deletions

View file

@ -25,6 +25,14 @@ PhotoTextsListItem {
openMenuOnPressAndHold: true//chat_id != overviewPage.ownUserId
menu: ContextMenu {
MenuItem {
visible: unread_count > 0
onClicked: {
tdLibWrapper.viewMessage(chat_id, display.last_message.id, true);
}
text: qsTr("Mark all messages as read")
}
MenuItem {
visible: chat_id != listItem.ownUserId
onClicked: {

View file

@ -290,7 +290,7 @@ Page {
chatPage.loading = false;
if (chatView.height > chatView.contentHeight) {
console.log("[ChatPage] Chat content quite small...");
tdLibWrapper.viewMessage(chatInformation.id, chatModel.getMessage(chatView.count - 1).id);
tdLibWrapper.viewMessage(chatInformation.id, chatModel.getMessage(chatView.count - 1).id, false);
}
}
onNewMessageReceived: {
@ -498,7 +498,7 @@ Page {
function handleScrollPositionChanged() {
console.log("Current position: " + chatView.contentY);
tdLibWrapper.viewMessage(chatInformation.id, chatView.itemAt(chatView.contentX, ( chatView.contentY + chatView.height - Theme.horizontalPageMargin )).myMessage.id);
tdLibWrapper.viewMessage(chatInformation.id, chatView.itemAt(chatView.contentX, ( chatView.contentY + chatView.height - Theme.horizontalPageMargin )).myMessage.id, false);
}
onContentYChanged: {

View file

@ -258,13 +258,13 @@ void TDLibWrapper::getChatHistory(const QString &chatId, const qlonglong &fromMe
this->sendRequest(requestObject);
}
void TDLibWrapper::viewMessage(const QString &chatId, const QString &messageId)
void TDLibWrapper::viewMessage(const QString &chatId, const QString &messageId, const bool &force = false)
{
LOG("Mark message as viewed" << chatId << messageId);
QVariantMap requestObject;
requestObject.insert(_TYPE, "viewMessages");
requestObject.insert("chat_id", chatId);
requestObject.insert("force_read", false);
requestObject.insert("force_read", force);
QVariantList messageIds;
messageIds.append(messageId);
requestObject.insert("message_ids", messageIds);

View file

@ -115,7 +115,7 @@ public:
Q_INVOKABLE void closeChat(const QString &chatId);
Q_INVOKABLE void leaveChat(const QString &chatId);
Q_INVOKABLE void getChatHistory(const QString &chatId, const qlonglong &fromMessageId = 0, const int &offset = 0, const int &limit = 50, const bool &onlyLocal = false);
Q_INVOKABLE void viewMessage(const QString &chatId, const QString &messageId);
Q_INVOKABLE void viewMessage(const QString &chatId, const QString &messageId, const bool &force);
Q_INVOKABLE void sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendPhotoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendVideoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");

View file

@ -226,6 +226,10 @@
<source>Group Info</source>
<translation>Gruppeninfos</translation>
</message>
<message>
<source>Mark all messages as read</source>
<translation>Nachrichten als gelesen markieren</translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -226,6 +226,10 @@
<source>Group Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark all messages as read</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -226,6 +226,10 @@
<source>Group Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark all messages as read</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -226,6 +226,10 @@
<source>Group Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark all messages as read</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -226,6 +226,10 @@
<source>Group Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark all messages as read</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -226,6 +226,10 @@
<source>Group Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark all messages as read</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -226,6 +226,10 @@
<source>Group Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark all messages as read</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -226,6 +226,10 @@
<source>Group Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark all messages as read</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -226,6 +226,10 @@
<source>Group Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark all messages as read</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatPage</name>