From 432e6a2663ffdf7076da8d386b8913925235b2bc Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 28 Dec 2025 04:55:09 +0000 Subject: [PATCH] Fix serializing zero notification count in never-read room case. Signed-off-by: Jason Volk --- src/api/client/sync/v3.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/api/client/sync/v3.rs b/src/api/client/sync/v3.rs index 1e83e092..dcd3f641 100644 --- a/src/api/client/sync/v3.rs +++ b/src/api/client/sync/v3.rs @@ -10,7 +10,7 @@ use futures::{ pin_mut, }; use ruma::{ - DeviceId, EventId, OwnedRoomId, OwnedUserId, RoomId, UserId, + DeviceId, EventId, OwnedRoomId, OwnedUserId, RoomId, UInt, UserId, api::client::{ filter::FilterDefinition, sync::sync_events::{ @@ -995,6 +995,13 @@ async fn load_joined_room( .flatten() .is_none_or(|last_count| last_count.gt(&since)); + let send_notification_resets = last_notification_read + .flatten() + .is_some_and(|last_count| last_count.gt(&since)); + + let send_notification_count_filter = + |count: &UInt| *count != uint!(0) || send_notification_resets; + let notification_count: OptionFuture<_> = send_notification_counts .then(|| { services @@ -1169,7 +1176,10 @@ async fn load_joined_room( .map(Event::into_format) .collect(), }, - unread_notifications: UnreadNotificationsCount { highlight_count, notification_count }, + unread_notifications: UnreadNotificationsCount { + highlight_count: highlight_count.filter(send_notification_count_filter), + notification_count: notification_count.filter(send_notification_count_filter), + }, unread_thread_notifications: BTreeMap::new(), };