fix: Address code review findings for NotificationsView (FRE-4737)

- P0: Add default param to protocol list(params:) for compile fix
- P1: Fix onDelete async closure, implement deletion logic
- P2: Remove redundant objectWillChange.send() (Published handles it)
- P2: Make RelativeDateTimeFormatter static singleton (per-row perf)
- P3: Replace deprecated NavigationView with NavigationStack
This commit is contained in:
2026-05-10 04:38:12 -04:00
parent c68cc9b8ee
commit ad6b4c9c1c
4 changed files with 18 additions and 18 deletions

View File

@@ -9,7 +9,7 @@ struct NotificationsView: View {
}
var body: some View {
NavigationView {
NavigationStack {
Group {
if viewModel.notifications.isEmpty && !viewModel.isLoading {
emptyStateView
@@ -18,7 +18,6 @@ struct NotificationsView: View {
}
}
.navigationTitle("Notifications")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
if !viewModel.notifications.isEmpty {
ToolbarItem(placement: .navigationBarTrailing) {
@@ -57,7 +56,15 @@ struct NotificationsView: View {
}
}
}
.onDelete(perform: deleteNotifications)
.onDelete { offsets in
Task {
for index in offsets {
let notification = viewModel.notifications[index]
await viewModel.markAsRead(id: notification.id)
}
viewModel.notifications.remove(atOffsets: offsets)
}
}
}
.listStyle(.insetGrouped)
.refreshable {
@@ -82,16 +89,7 @@ struct NotificationsView: View {
.multilineTextAlignment(.center)
.padding(.horizontal, 32)
}
.padding(.vertical, 60)
}
private func deleteNotifications(at offsets: IndexSet) async {
// TODO: Implement notification deletion logic
// This would typically call a delete API endpoint
for index in offsets {
let notification = viewModel.notifications[index]
// await notificationsService.delete(id: notification.id)
}
.padding(.vertical, 60)
}
}