From 2e371b5296ab1311b9591a191d5e7764a9b77dd4 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 23 Nov 2025 12:45:19 +0800 Subject: [PATCH] :lipstick: More accurate notification unread count --- lib/screens/notification.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/screens/notification.dart b/lib/screens/notification.dart index 4f6d4688..001bcba2 100644 --- a/lib/screens/notification.dart +++ b/lib/screens/notification.dart @@ -68,6 +68,16 @@ class NotificationUnreadCountNotifier void clear() async { state = AsyncData(0); } + + Future refresh() async { + try { + final client = ref.read(apiClientProvider); + final response = await client.get('/ring/notifications/count'); + state = AsyncData((response.data as num).toInt()); + } catch (_) { + // Keep the current state if refresh fails + } + } } @riverpod @@ -117,6 +127,9 @@ class NotificationSheet extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + // Refresh unread count when sheet opens to sync across devices + ref.read(notificationUnreadCountNotifierProvider.notifier).refresh(); + Future markAllRead() async { showLoadingModal(context); final apiClient = ref.watch(apiClientProvider);