mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 16:31:00 +00:00
Fix notifications reload
This commit is contained in:
parent
00e35be2d5
commit
b83f7e9a55
2 changed files with 12 additions and 8 deletions
|
@ -39,7 +39,6 @@ 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"
|
||||||
|
@ -64,6 +63,9 @@ public struct NotificationsListView: View {
|
||||||
ToolbarTitleMenu {
|
ToolbarTitleMenu {
|
||||||
Button {
|
Button {
|
||||||
viewModel.selectedType = nil
|
viewModel.selectedType = nil
|
||||||
|
Task {
|
||||||
|
await viewModel.fetchNotifications()
|
||||||
|
}
|
||||||
} label: {
|
} label: {
|
||||||
Label("notifications.navigation-title", systemImage: "bell.fill")
|
Label("notifications.navigation-title", systemImage: "bell.fill")
|
||||||
}
|
}
|
||||||
|
@ -71,6 +73,9 @@ public struct NotificationsListView: View {
|
||||||
ForEach(Notification.NotificationType.allCases, id: \.self) { type in
|
ForEach(Notification.NotificationType.allCases, id: \.self) { type in
|
||||||
Button {
|
Button {
|
||||||
viewModel.selectedType = type
|
viewModel.selectedType = type
|
||||||
|
Task {
|
||||||
|
await viewModel.fetchNotifications()
|
||||||
|
}
|
||||||
} label: {
|
} label: {
|
||||||
Label {
|
Label {
|
||||||
Text(type.menuTitle())
|
Text(type.menuTitle())
|
||||||
|
@ -87,15 +92,19 @@ public struct NotificationsListView: View {
|
||||||
.scrollContentBackground(.hidden)
|
.scrollContentBackground(.hidden)
|
||||||
.background(theme.primaryBackgroundColor)
|
.background(theme.primaryBackgroundColor)
|
||||||
#endif
|
#endif
|
||||||
.task {
|
.onAppear {
|
||||||
viewModel.client = client
|
viewModel.client = client
|
||||||
viewModel.currentAccount = account
|
viewModel.currentAccount = account
|
||||||
if let lockedType {
|
if let lockedType {
|
||||||
viewModel.isLockedType = true
|
viewModel.isLockedType = true
|
||||||
viewModel.selectedType = lockedType
|
viewModel.selectedType = lockedType
|
||||||
|
} else {
|
||||||
|
viewModel.loadSelectedType()
|
||||||
}
|
}
|
||||||
|
Task {
|
||||||
await viewModel.fetchNotifications()
|
await viewModel.fetchNotifications()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.refreshable {
|
.refreshable {
|
||||||
SoundEffectManager.shared.playSound(.pull)
|
SoundEffectManager.shared.playSound(.pull)
|
||||||
HapticManager.shared.fireHaptic(.dataRefresh(intensity: 0.3))
|
HapticManager.shared.fireHaptic(.dataRefresh(intensity: 0.3))
|
||||||
|
|
|
@ -50,15 +50,10 @@ import SwiftUI
|
||||||
}
|
}
|
||||||
|
|
||||||
consolidatedNotifications = []
|
consolidatedNotifications = []
|
||||||
Task {
|
|
||||||
await fetchNotifications()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadSelectedType() {
|
func loadSelectedType() {
|
||||||
client = client
|
|
||||||
|
|
||||||
guard let value = UserDefaults.standard.string(forKey: filterKey)
|
guard let value = UserDefaults.standard.string(forKey: filterKey)
|
||||||
else {
|
else {
|
||||||
selectedType = nil
|
selectedType = nil
|
||||||
|
|
Loading…
Reference in a new issue