From fa978a7cd1833b348cd4fc6e243620ecdbc20042 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 1 Jan 2025 11:50:06 +0800 Subject: [PATCH] :bug: Fix notification mark all as read issue --- lib/screens/notification.dart | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/screens/notification.dart b/lib/screens/notification.dart index 21cf51f..1e9ec8f 100644 --- a/lib/screens/notification.dart +++ b/lib/screens/notification.dart @@ -82,24 +82,15 @@ class _NotificationScreenState extends State { if (!mounted) return; setState(() => _isSubmitting = true); - List markList = List.empty(growable: true); - for (final element in _notifications) { - if (element.id <= 0) continue; - if (element.readAt != null) continue; - markList.add(element.id); - } - try { final sn = context.read(); - await sn.client.put('/cgi/id/notifications/read', data: { - 'messages': markList, - }); + final resp = await sn.client.put('/cgi/id/notifications/read/all'); _notifications.clear(); _fetchNotifications(); if (!mounted) return; context.showSnackbar( - 'notificationMarkAllReadPrompt'.plural(markList.length), + 'notificationMarkAllReadPrompt'.plural(resp.data['count']), ); } catch (err) { if (!mounted) return;