Skip to content

Commit a2ed226

Browse files
Dimillianjesusjimsa
authored andcommitted
Fix notifications filter reset (Dimillian#2343)
1 parent b82737d commit a2ed226

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Packages/Notifications/Sources/Notifications/List/NotificationsListView.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,15 @@ public struct NotificationsListView: View {
7070
if lockedType == nil && lockedAccountId == nil {
7171
ToolbarTitleMenu {
7272
Button {
73-
selectedType = nil
74-
Task {
75-
viewState = .loading
76-
await fetchNotifications()
77-
}
73+
applyFilter(type: nil)
7874
} label: {
7975
Label("notifications.navigation-title", systemImage: "bell.fill")
8076
.tint(theme.labelColor)
8177
}
8278
Divider()
8379
ForEach(Notification.NotificationType.allCases, id: \.self) { type in
8480
Button {
85-
selectedType = type
86-
Task {
87-
viewState = .loading
88-
await fetchNotifications()
89-
}
81+
applyFilter(type: type)
9082
} label: {
9183
Label {
9284
Text(type.menuTitle())
@@ -277,6 +269,16 @@ public struct NotificationsListView: View {
277269
}
278270

279271
extension NotificationsListView {
272+
private func applyFilter(type: Models.Notification.NotificationType?) {
273+
selectedType = type
274+
dataSource.reset()
275+
viewState = .loading
276+
277+
Task {
278+
await fetchNotifications()
279+
}
280+
}
281+
280282
private func fetchNotifications() async {
281283
do {
282284
let result = try await dataSource.fetchNotifications(

0 commit comments

Comments
 (0)