Page MenuHomePhorge

D205.1732745095.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D205.1732745095.diff

diff --git a/src/contents/ui/RoomListViewItemDelegate.qml b/src/contents/ui/RoomListViewItemDelegate.qml
--- a/src/contents/ui/RoomListViewItemDelegate.qml
+++ b/src/contents/ui/RoomListViewItemDelegate.qml
@@ -26,7 +26,7 @@
}
property var roomDisplayName: roomNameProvider.name
property var roomTimeline: item.timeline()
- property var lastUnreadMessage: getLastUnreadMessage(roomTimeline, roomTimeline.count)
+ property var lastUnreadMessage: getLastUnreadMessage(roomTimeline, roomTimeline.count, item)
property var lastUnreadMessageReaders: lastUnreadMessage ? lastUnreadMessage.readers() : null
// The readers count is to make hasUnreadMessages prop reactive
// against our newly-posted receipts
@@ -145,14 +145,17 @@
}
function getHasUnreadMessages(room, timeline, timelineCount, readersCount) {
- return !!room.unreadNotificationCount || !!getLastUnreadMessage(timeline, timelineCount);
+ return !!room.unreadNotificationCount || !!getLastUnreadMessage(timeline, timelineCount, room);
}
- function getLastUnreadMessage(timeline, timelineCount) {
+ function getLastUnreadMessage(timeline, timelineCount, room) {
for (let i = 0; i < timelineCount; ++i) {
const event = timeline.at(i);
if (event.isLocalEcho) {
// Skip local echoes
+ } else if (room.localReadMarker === event.eventId) {
+ // This message is read locally
+ return undefined;
} else if (event.sender === matrixSdk.userId) {
// Own message here
return undefined;
diff --git a/src/matrix-room.hpp b/src/matrix-room.hpp
--- a/src/matrix-room.hpp
+++ b/src/matrix-room.hpp
@@ -67,6 +67,7 @@
LAGER_QT_READER(QStringList, tagIds);
LAGER_QT_READER(Membership, membership);
LAGER_QT_READER(int, unreadNotificationCount);
+ LAGER_QT_READER(QString, localReadMarker);
Q_INVOKABLE MatrixRoomMember *memberAt(int index) const;
diff --git a/src/matrix-room.cpp b/src/matrix-room.cpp
--- a/src/matrix-room.cpp
+++ b/src/matrix-room.cpp
@@ -87,6 +87,7 @@
}))
, LAGER_QT(membership)(m_room.membership().map([](const auto &membership) { return static_cast<Membership>(membership); }))
, LAGER_QT(unreadNotificationCount)(m_room.unreadNotificationEventIds().map([](const auto &cont) -> int { return cont.size(); }))
+ , LAGER_QT(localReadMarker)(m_room.localReadMarker().xform(strToQt))
, m_setTypingThrottled(QFunctionUtils::Throttle([self=QPointer<MatrixRoom>(this)]() {
if (self) {
self->setTypingImpl();
diff --git a/src/tests/quick-tests/tst_RoomListViewItemDelegate.qml b/src/tests/quick-tests/tst_RoomListViewItemDelegate.qml
--- a/src/tests/quick-tests/tst_RoomListViewItemDelegate.qml
+++ b/src/tests/quick-tests/tst_RoomListViewItemDelegate.qml
@@ -258,11 +258,15 @@
}
function test_lastUnreadMessage() {
- compare(delegateJoin.getLastUnreadMessage(timelineUnread, timelineUnread.count).eventId, '$event2');
+ const room = {};
+ compare(delegateJoin.getLastUnreadMessage(timelineUnread, timelineUnread.count, room).eventId, '$event2');
- compare(delegateJoin.getLastUnreadMessage(timelineLastSentIsMine, timelineLastSentIsMine.count), undefined);
+ compare(delegateJoin.getLastUnreadMessage(timelineLastSentIsMine, timelineLastSentIsMine.count, room), undefined);
- compare(delegateJoin.getLastUnreadMessage(timelineRead, timelineRead.count), undefined);
+ compare(delegateJoin.getLastUnreadMessage(timelineRead, timelineRead.count, room), undefined);
+
+ room.localReadMarker = '$event2';
+ compare(delegateJoin.getLastUnreadMessage(timelineUnread, timelineUnread.count, room), undefined);
}
function test_returnRoom() {

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 2:04 PM (21 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38684
Default Alt Text
D205.1732745095.diff (3 KB)

Event Timeline