feat: setQueryData after collecting and uncollecting

This commit is contained in:
DIYgod 2024-05-22 11:35:09 +08:00
parent b3e4270c03
commit 02573a67ca
No known key found for this signature in database
1 changed files with 14 additions and 6 deletions

View File

@ -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.",
@ -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.",