mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 09:41:02 +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,18 +36,35 @@ import SwiftUI
|
|||
|
||||
var currentAccount: CurrentAccount?
|
||||
|
||||
private let filterKey = "notification-filter"
|
||||
var state: State = .loading
|
||||
var selectedType: Models.Notification.NotificationType? {
|
||||
didSet {
|
||||
if oldValue != selectedType {
|
||||
consolidatedNotifications = []
|
||||
Task {
|
||||
await fetchNotifications()
|
||||
}
|
||||
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
|
||||
|
||||
private var queryTypes: [String]? {
|
||||
|
|
Loading…
Reference in a new issue