Skip to content

Commit

Permalink
feat: setQueryData after collecting and uncollecting
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed May 22, 2024
1 parent b3e4270 commit 02573a6
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/renderer/src/hooks/useEntryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ export const useEntryActions = ({
},
}),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ["entries"],
})
queryClient.setQueryData(
["entry", entry.id],
Object.assign({}, entry, {
collections: {
createdAt: new Date().toISOString(),
},
}),
)
toast({
duration: 1000,
description: "Collected.",
Expand All @@ -53,9 +58,12 @@ export const useEntryActions = ({
},
}),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ["entries"],
})
queryClient.setQueryData(
["entry", entry.id],
Object.assign({}, entry, {
collections: null,
}),
)
toast({
duration: 1000,
description: "Uncollected.",
Expand Down

0 comments on commit 02573a6

Please sign in to comment.