diff --git a/src/services/hooks/extension/get-notifications.hook.ts b/src/services/hooks/extension/get-notifications.hook.ts index 763b05f7..ddc29653 100644 --- a/src/services/hooks/extension/get-notifications.hook.ts +++ b/src/services/hooks/extension/get-notifications.hook.ts @@ -1,4 +1,4 @@ -import { useMutation, useQuery } from '@tanstack/react-query' +import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { getMainClient } from '@/services/api' import { getFromStorage, setToStorage } from '@/common/storage' @@ -84,11 +84,17 @@ export function useGetNotifications() { } export function useNotifyAsSeen() { + const queryClient = useQueryClient() return useMutation({ mutationFn: async (id: string) => { const client = getMainClient() await client.put(`/notifications/${id}/seen`) }, + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: ['notifications'], + }) + }, mutationKey: ['seen_notification'], }) }