Skip to content

Sliding Sync RoomData overwrites notification counts #4812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RickyRoller opened this issue Apr 17, 2025 · 1 comment
Open

Sliding Sync RoomData overwrites notification counts #4812

RickyRoller opened this issue Apr 17, 2025 · 1 comment
Labels
A-Notifications O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Impairs non-critical functionality or suitable workarounds exist T-Defect

Comments

@RickyRoller
Copy link

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

@dosubot dosubot bot added the T-Defect label Apr 17, 2025
@dbkr
Copy link
Member

dbkr commented Apr 22, 2025

Very possible: you'll probably find the same logic is implemented for threads here: #4770 and this is all somewhat up-in-the-air as support is still landing in synapse, but yes, we should certainly be applying the same logic in sliding sync as for sync.

@dbkr dbkr added A-Notifications O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Impairs non-critical functionality or suitable workarounds exist labels Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Notifications O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Impairs non-critical functionality or suitable workarounds exist T-Defect
Projects
None yet
Development

No branches or pull requests

2 participants