Skip to content

Commit d6e9e06

Browse files
Francisca105luckspt
authored andcommitted
fix: update notification type in mutation
1 parent d9bcc9b commit d6e9e06

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

frontend/src/mutations/notifications.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
deleteAllMyNotifications,
44
deleteMyNotification,
55
} from "@/api/notifications";
6-
import type { EnrichedNotification } from "@/dto/notifications";
6+
import type { Notification } from "@/dto/notifications";
77

88
export const useDeleteNotificationMutation = defineMutation(() => {
99
const queryCache = useQueryCache();
@@ -12,12 +12,14 @@ export const useDeleteNotificationMutation = defineMutation(() => {
1212
mutation: (id: string) => deleteMyNotification(id),
1313
onMutate: (id: string) => {
1414
// optimistic: remove the notification from the "notifications" query
15-
const prev = queryCache.getQueryData<{ data: EnrichedNotification[] }>([
15+
const prev = queryCache.getQueryData<{ data: Notification[] }>([
1616
"notifications",
1717
]) || {
1818
data: [],
1919
};
20-
const newData = (prev.data || []).filter((n) => n.id !== id);
20+
const newData = (prev.data || []).filter(
21+
(n) => (n as Notification).id !== id,
22+
);
2123
queryCache.setQueryData(["notifications"], { ...prev, data: newData });
2224
// cancel ongoing queries
2325
queryCache.cancelQueries({ key: ["notifications"] });

0 commit comments

Comments
 (0)