mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-25 14:32:20 +01:00
More accurate notifications badge
This commit is contained in:
parent
105b7717a9
commit
c4daa73932
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user