From c9dc5e12b835425f1ba5c447ddb3c3394ccac93e Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 3 Oct 2017 16:16:38 +0900 Subject: Room: cache unread indicator inside m.read content, not next to it The CS API, turns out, has a quite official extension point inside m.read event content - clients are allowed to put whatever extra data they feel reasonable. --- events/receiptevent.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'events') diff --git a/events/receiptevent.cpp b/events/receiptevent.cpp index 3d6be9f1..646bb989 100644 --- a/events/receiptevent.cpp +++ b/events/receiptevent.cpp @@ -66,6 +66,11 @@ ReceiptEvent::ReceiptEvent(const QJsonObject& obj) } _eventsWithReceipts.push_back({eventIt.key(), receipts}); } - _unreadMessages = obj["x-qmatrixclient.unread_messages"].toBool(); + static const auto UnreadMsgsKey = + QStringLiteral("x-qmatrixclient.unread_messages"); + if (contents.contains(UnreadMsgsKey)) + _unreadMessages = contents["x-qmatrixclient.unread_messages"].toBool(); + else + _unreadMessages = obj["x-qmatrixclient.unread_messages"].toBool(); } -- cgit v1.2.3