From 47ff9f3aa52bd66280f0c2cdc3af5c31ea10eb7a Mon Sep 17 00:00:00 2001 From: Nguyen Ngo Date: Tue, 23 Jun 2026 10:11:31 -0400 Subject: [PATCH] 06/23 Fix notifications issue --- JanitorialQC/Sync/SyncManager.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/JanitorialQC/Sync/SyncManager.swift b/JanitorialQC/Sync/SyncManager.swift index 1fe537e..aaba008 100644 --- a/JanitorialQC/Sync/SyncManager.swift +++ b/JanitorialQC/Sync/SyncManager.swift @@ -140,16 +140,16 @@ class SyncManager: ObservableObject { recentNotifications = notifications + recentNotifications.prefix(50 - 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) } if let newest = dates.max() { 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 { // Token expired and refresh failed — let AuthManager handle it } catch {