mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-14 05:21:12 +00:00
* store selected notification filter (#1627) * store one filter for all accounts
This commit is contained in:
parent
58d6a3b472
commit
4b74532048
2 changed files with 23 additions and 5 deletions
|
@ -39,6 +39,7 @@ public struct NotificationsListView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onAppear { viewModel.loadSelectedType() }
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .principal) {
|
||||
let title = lockedType?.menuTitle() ?? viewModel.selectedType?.menuTitle() ?? "notifications.navigation-title"
|
||||
|
|
|
@ -36,16 +36,33 @@ import SwiftUI
|
|||
|
||||
var currentAccount: CurrentAccount?
|
||||
|
||||
private let filterKey = "notification-filter"
|
||||
var state: State = .loading
|
||||
var selectedType: Models.Notification.NotificationType? {
|
||||
didSet {
|
||||
if oldValue != selectedType {
|
||||
guard oldValue != selectedType,
|
||||
let id = client?.id
|
||||
else { return }
|
||||
|
||||
UserDefaults.standard.set(selectedType?.rawValue ?? "", forKey: filterKey)
|
||||
|
||||
consolidatedNotifications = []
|
||||
Task {
|
||||
await fetchNotifications()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func loadSelectedType() {
|
||||
self.client = client
|
||||
|
||||
guard let value = UserDefaults.standard.string(forKey: filterKey)
|
||||
else {
|
||||
selectedType = nil
|
||||
return
|
||||
}
|
||||
|
||||
selectedType = .init(rawValue: value)
|
||||
}
|
||||
|
||||
var scrollToTopVisible: Bool = false
|
||||
|
|
Loading…
Reference in a new issue