mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-14 13:31:05 +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 {
|
.toolbar {
|
||||||
ToolbarItem(placement: .principal) {
|
ToolbarItem(placement: .principal) {
|
||||||
let title = lockedType?.menuTitle() ?? viewModel.selectedType?.menuTitle() ?? "notifications.navigation-title"
|
let title = lockedType?.menuTitle() ?? viewModel.selectedType?.menuTitle() ?? "notifications.navigation-title"
|
||||||
|
|
|
@ -36,16 +36,33 @@ import SwiftUI
|
||||||
|
|
||||||
var currentAccount: CurrentAccount?
|
var currentAccount: CurrentAccount?
|
||||||
|
|
||||||
|
private let filterKey = "notification-filter"
|
||||||
var state: State = .loading
|
var state: State = .loading
|
||||||
var selectedType: Models.Notification.NotificationType? {
|
var selectedType: Models.Notification.NotificationType? {
|
||||||
didSet {
|
didSet {
|
||||||
if oldValue != selectedType {
|
guard oldValue != selectedType,
|
||||||
|
let id = client?.id
|
||||||
|
else { return }
|
||||||
|
|
||||||
|
UserDefaults.standard.set(selectedType?.rawValue ?? "", forKey: filterKey)
|
||||||
|
|
||||||
consolidatedNotifications = []
|
consolidatedNotifications = []
|
||||||
Task {
|
Task {
|
||||||
await fetchNotifications()
|
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
|
var scrollToTopVisible: Bool = false
|
||||||
|
|
Loading…
Reference in a new issue