Description
When using sliding sync, the notification counts will get overwritten by the RoomData handler.
matrix-js-sdk/src/sliding-sync-sdk.ts
Lines 623 to 625 in 69f1bea
This is assuming that the RoomData count is more accurate that what we have in the Room's state, but this isn't the case with encrypted rooms.
Below, the highlight counters are not being overwritten with encrypted rooms, but for some reason it isn't being done for regular notification counts.
I added some logging to the code to double check and here are the results:
if (roomData.notification_count != null) {
console.log(room.getUnreadNotificationCount(NotificationCountType.Total), roomData.notification_count);
room.setUnreadNotificationCount(NotificationCountType.Total, roomData.notification_count);
}
10 0
This lines up with what I'm seeing. On reload, the room shows 10 (I'm only getting the last 10 timeline events with Sliding Sync), and then when a new message comes in it's reset to 1
If we use the same encryption check as the highlight count, it works as expected. Is there a reason we shouldn't implement it the same way?
If not, I'm happy to open a PR with the change