aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlink2xt <link2xt@testrun.org>2021-03-16 05:25:52 +0300
committerlink2xt <link2xt@testrun.org>2021-03-19 03:13:33 +0300
commit1b79a5d06f02035db165b7a2c294df1006a503ed (patch)
treecc0b2b0505c629c3f08832f259285892bda95745
parenta21b68a39a3acfe2f82df274c51afffcfe60fe1c (diff)
downloadkdeltachat-1b79a5d06f02035db165b7a2c294df1006a503ed.tar.gz
kdeltachat-1b79a5d06f02035db165b7a2c294df1006a503ed.zip
Mark displayed messages as seen
-rw-r--r--context.cpp6
-rw-r--r--context.h1
-rw-r--r--main.cpp1
-rw-r--r--qml/ChatPage.qml5
-rw-r--r--qml/Message.qml6
5 files changed, 18 insertions, 1 deletions
diff --git a/context.cpp b/context.cpp
index 6a7148a..89a7937 100644
--- a/context.cpp
+++ b/context.cpp
@@ -117,6 +117,12 @@ Context::marknoticedChat(uint32_t chatId) {
return dc_marknoticed_chat(m_context, chatId);
}
+void
+Context::markseenMsgs(QVector<uint32_t> msg_ids)
+{
+ dc_markseen_msgs(m_context, msg_ids.constData(), msg_ids.count());
+}
+
DcMessage *
Context::getMessage(uint32_t msgId)
{
diff --git a/context.h b/context.h
index c8d9691..0ca4c04 100644
--- a/context.h
+++ b/context.h
@@ -34,6 +34,7 @@ public:
Q_INVOKABLE QVariantList getMsgIdList(uint32_t chatId);
Q_INVOKABLE int getFreshMsgCnt(uint32_t chatId);
Q_INVOKABLE void marknoticedChat(uint32_t chatId);
+ Q_INVOKABLE void markseenMsgs(QVector<uint32_t> msg_ids);
Q_INVOKABLE DcMessage *getMessage(uint32_t msgId);
Q_INVOKABLE DcContact *getContact(uint32_t contactId);
Q_INVOKABLE uint32_t sendTextMessage(uint32_t chatId, QString textToSend);
diff --git a/main.cpp b/main.cpp
index f2687e0..8b883b2 100644
--- a/main.cpp
+++ b/main.cpp
@@ -55,6 +55,7 @@ int main(int argc, char *argv[])
}
qRegisterMetaType<size_t>("size_t");
qRegisterMetaType<uint32_t>("uint32_t");
+ qRegisterMetaType<QVector<uint32_t>>("QVector<uint32_t>");
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/qml/main.qml"));
diff --git a/qml/ChatPage.qml b/qml/ChatPage.qml
index ecc2383..97d8069 100644
--- a/qml/ChatPage.qml
+++ b/qml/ChatPage.qml
@@ -135,7 +135,10 @@ Kirigami.ScrollablePage {
*/
verticalLayoutDirection: ListView.BottomToTop
- delegate: Message {message: context.getMessage(msgId)}
+ delegate: Message {
+ message: chatPage.context.getMessage(msgId)
+ context: chatPage.context
+ }
}
footer: Loader {
diff --git a/qml/Message.qml b/qml/Message.qml
index 2c67cff..6fc0318 100644
--- a/qml/Message.qml
+++ b/qml/Message.qml
@@ -12,6 +12,8 @@ RowLayout {
id: messageObject
property DcMessage message
+ property DcContext context
+
readonly property DcContact from: context.getContact(message.fromId)
readonly property DcMessage quoteMessage: message.quotedMessage
readonly property DcContact quoteFrom: quoteMessage ? context.getContact(quoteMessage.fromId) : null
@@ -24,6 +26,10 @@ RowLayout {
: messageObject.message.fromId > 0 ? messageObject.from.displayName
: ""
+ Component.onCompleted: {
+ messageObject.context.markseenMsgs([messageObject.message.id])
+ }
+
Rectangle {
Layout.preferredWidth: messageContents.width
Layout.preferredHeight: messageContents.height