fix: Set unread notification count only if not null in sync

Fixes an edge case in the sdk
which sets the unread
notification count wrongly to 0 on room fake sync.
This commit is contained in:
Christian Kußowski 2025-09-12 15:20:18 +02:00
parent 82d6318293
commit d3497cac68
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
2 changed files with 9 additions and 4 deletions

View File

@ -2979,10 +2979,13 @@ class Client extends MatrixApi {
rooms[roomIndex].prev_batch = chatUpdate.timeline?.prevBatch;
}
rooms[roomIndex].membership = membership;
rooms[roomIndex].notificationCount =
chatUpdate.unreadNotifications?.notificationCount ?? 0;
rooms[roomIndex].highlightCount =
chatUpdate.unreadNotifications?.highlightCount ?? 0;
if (chatUpdate.unreadNotifications != null) {
rooms[roomIndex].notificationCount =
chatUpdate.unreadNotifications?.notificationCount ?? 0;
rooms[roomIndex].highlightCount =
chatUpdate.unreadNotifications?.highlightCount ?? 0;
}
final summary = chatUpdate.summary;
if (summary != null) {

View File

@ -295,6 +295,8 @@ void main() {
),
);
expect(room.hasNewMessages, true);
expect(room.isUnreadOrInvited, true);
room.notificationCount = room.highlightCount = 0;
expect(room.isUnreadOrInvited, false);
expect(room.lastEvent?.body, 'cd');
await updateLastEvent(