06/23 Fix notifications issue

This commit is contained in:
Nguyen Ngo
2026-06-23 10:11:31 -04:00
parent 072ea13b53
commit 47ff9f3aa5
+5 -5
View File
@@ -140,16 +140,16 @@ class SyncManager: ObservableObject {
recentNotifications = notifications + recentNotifications.prefix(50 - notifications.count) recentNotifications = notifications + recentNotifications.prefix(50 - notifications.count)
unreadNotificationCount += notifications.count unreadNotificationCount += notifications.count
// Update the cursor to the newest notification's timestamp // Update the cursor to the newest notification's timestamp so the
// next poll only fetches newer items do NOT mark notifications as
// read on the server. Read state is a deliberate user action managed
// via the web app; marking read here would cause the web badge count
// to always show zero when the iPad has polled before the user checks.
let dates = notifications.compactMap { Self.isoFormatter.date(from: $0.createdAt) } let dates = notifications.compactMap { Self.isoFormatter.date(from: $0.createdAt) }
if let newest = dates.max() { if let newest = dates.max() {
lastNotificationFetch = newest lastNotificationFetch = newest
} }
// Mark all fetched notifications as read on the server
let ids = notifications.map(\.id)
try await APIClient.shared.markNotificationsRead(ids: ids)
} catch APIError.notAuthenticated { } catch APIError.notAuthenticated {
// Token expired and refresh failed let AuthManager handle it // Token expired and refresh failed let AuthManager handle it
} catch { } catch {