From 01dfdb29fd7725dbb18e097a5daceb57b90baa78 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Tue, 15 Feb 2022 10:18:18 +0100 Subject: [PATCH 1/2] fix: Has new messages compares ts This compares the origin server timestamp which might not map to the real sort order of the timeline. But it is the best solution for now. --- lib/src/room.dart | 10 +++++++++- test/room_test.dart | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index 759ec54b..02a59c3e 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -508,6 +508,8 @@ class Room { } /// Checks if the last event has a read marker of the user. + /// Warning: This compares the origin server timestamp which might not map + /// to the real sort order of the timeline. bool get hasNewMessages { final lastEvent = this.lastEvent; @@ -522,7 +524,13 @@ class Room { return false; } - return true; + final readAtMilliseconds = roomAccountData['m.receipt'] + ?.content + .tryGetMap(client.userID!) + ?.tryGet('ts') ?? + 0; + + return readAtMilliseconds < lastEvent.originServerTs.millisecondsSinceEpoch; } /// Returns true if this room is unread. To check if there are new messages diff --git a/test/room_test.dart b/test/room_test.dart index ffd49630..6b67186f 100644 --- a/test/room_test.dart +++ b/test/room_test.dart @@ -185,6 +185,7 @@ void main() { stateKey: '', ), ); + expect(room.hasNewMessages, true); expect(room.lastEvent?.body, 'cd'); room.setState( Event( From 645443a319d0b707272dc97e9f7e8189f0d98b53 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Tue, 15 Feb 2022 11:23:28 +0100 Subject: [PATCH 2/2] chore: Bump version --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 756af671..0257bf00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [0.8.8] - 14nd Feb 2022 +- fix: Has new messages compares ts +- fix: handle dynamic content for pinned events + ## [0.8.7] - 14nd Feb 2022 - fix: Show reactions as last events and refactor hasNewMessage diff --git a/pubspec.yaml b/pubspec.yaml index bca313a1..ec815cf5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: matrix description: Matrix Dart SDK -version: 0.8.7 +version: 0.8.8 homepage: https://famedly.com repository: https://gitlab.com/famedly/company/frontend/famedlysdk.git