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/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/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 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(