06/23 Fix notifications issue
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user