Fix notifications reload
This commit is contained in:
parent
00e35be2d5
commit
b83f7e9a55
|
@ -39,7 +39,6 @@ public struct NotificationsListView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onAppear { viewModel.loadSelectedType() }
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .principal) {
|
||||
let title = lockedType?.menuTitle() ?? viewModel.selectedType?.menuTitle() ?? "notifications.navigation-title"
|
||||
|
@ -64,6 +63,9 @@ public struct NotificationsListView: View {
|
|||
ToolbarTitleMenu {
|
||||
Button {
|
||||
viewModel.selectedType = nil
|
||||
Task {
|
||||
await viewModel.fetchNotifications()
|
||||
}
|
||||
} label: {
|
||||
Label("notifications.navigation-title", systemImage: "bell.fill")
|
||||
}
|
||||
|
@ -71,6 +73,9 @@ public struct NotificationsListView: View {
|
|||
ForEach(Notification.NotificationType.allCases, id: \.self) { type in
|
||||
Button {
|
||||
viewModel.selectedType = type
|
||||
Task {
|
||||
await viewModel.fetchNotifications()
|
||||
}
|
||||
} label: {
|
||||
Label {
|
||||
Text(type.menuTitle())
|
||||
|
@ -87,14 +92,18 @@ public struct NotificationsListView: View {
|
|||
.scrollContentBackground(.hidden)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
.task {
|
||||
.onAppear {
|
||||
viewModel.client = client
|
||||
viewModel.currentAccount = account
|
||||
if let lockedType {
|
||||
viewModel.isLockedType = true
|
||||
viewModel.selectedType = lockedType
|
||||
} else {
|
||||
viewModel.loadSelectedType()
|
||||
}
|
||||
Task {
|
||||
await viewModel.fetchNotifications()
|
||||
}
|
||||
await viewModel.fetchNotifications()
|
||||
}
|
||||
.refreshable {
|
||||
SoundEffectManager.shared.playSound(.pull)
|
||||
|
|
|
@ -50,15 +50,10 @@ import SwiftUI
|
|||
}
|
||||
|
||||
consolidatedNotifications = []
|
||||
Task {
|
||||
await fetchNotifications()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func loadSelectedType() {
|
||||
client = client
|
||||
|
||||
guard let value = UserDefaults.standard.string(forKey: filterKey)
|
||||
else {
|
||||
selectedType = nil
|
||||
|
|
Loading…
Reference in New Issue