Skip to content

Sliding Sync RoomData overwrites notification counts #4812

Open
@RickyRoller

Description

@RickyRoller

When using sliding sync, the notification counts will get overwritten by the RoomData handler.

if (roomData.notification_count != null) {
room.setUnreadNotificationCount(NotificationCountType.Total, roomData.notification_count);
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NotificationsO-OccasionalAffects or can be seen by some users regularly or most users rarelyS-MinorImpairs non-critical functionality or suitable workarounds existT-Defect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions