diff --git a/IceCubesApp/App/Tabs/NotificationTab.swift b/IceCubesApp/App/Tabs/NotificationTab.swift index 585684e3..ad22e74c 100644 --- a/IceCubesApp/App/Tabs/NotificationTab.swift +++ b/IceCubesApp/App/Tabs/NotificationTab.swift @@ -49,6 +49,9 @@ struct NotificationsTab: View { } .onAppear { routerPath.client = client + if isSecondaryColumn { + clearNotifications() + } } .withSafariRouter() .environmentObject(routerPath) @@ -74,12 +77,7 @@ struct NotificationsTab: View { .onChange(of: scenePhase, perform: { scenePhase in switch scenePhase { case .active: - if isSecondaryColumn { - if let token = appAccount.currentAccount.oauthToken { - userPreferences.setNotification(count: 0, token: token) - } - watcher.unreadNotificationsCount = 0 - } + clearNotifications() default: break } @@ -88,4 +86,13 @@ struct NotificationsTab: View { routerPath.path = [] } } + + private func clearNotifications() { + if isSecondaryColumn { + if let token = appAccount.currentAccount.oauthToken { + userPreferences.setNotification(count: 0, token: token) + } + watcher.unreadNotificationsCount = 0 + } + } } diff --git a/Packages/Env/Sources/Env/UserPreferences.swift b/Packages/Env/Sources/Env/UserPreferences.swift index db6272df..3e96933d 100644 --- a/Packages/Env/Sources/Env/UserPreferences.swift +++ b/Packages/Env/Sources/Env/UserPreferences.swift @@ -95,6 +95,7 @@ public class UserPreferences: ObservableObject { public func setNotification(count: Int, token: OauthToken) { Self.sharedDefault?.set(count, forKey: "push_notifications_count_\(token.createdAt)") + objectWillChange.send() } public func getNotificationsCount(for token: OauthToken) -> Int {