We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 59d1944 commit bbd6f90Copy full SHA for bbd6f90
src/queries/definition/comment.ts
@@ -109,13 +109,24 @@ export const useReplyCommentMutation = () => {
109
},
110
})
111
112
- onSuccess: () => {
113
- queryClient.invalidateQueries({
114
- queryKey: commentAdmin.byState(state).queryKey,
115
- })
+ onMutate({ id }) {
+ queryClient.setQueryData<InfiniteData<PaginateResult<CommentModel>>>(
+ commentAdmin.byState(state).queryKey,
+ produce((draft) => {
116
+ draft?.pages.forEach((page) => {
117
+ page.data = page.data.filter((comment) => comment.id !== id)
118
+ })
119
+ }),
120
+ )
121
+ },
122
+ onSuccess: (_) => {
123
toast.success('回复成功')
124
125
onError: () => {
126
+ queryClient.invalidateQueries({
127
+ queryKey: commentAdmin.byState(state).queryKey,
128
129
+
130
toast.error('回复失败')
131
132
0 commit comments