1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Rewrite header actions

This commit is contained in:
Zhiyuan Zheng
2020-12-19 18:21:37 +01:00
parent 54799aabb8
commit 98a60df9d1
9 changed files with 152 additions and 104 deletions

View File

@ -70,14 +70,8 @@ const HeaderDefaultActionsAccount: React.FC<Props> = ({
}) => {
const queryClient = useQueryClient()
const { mutate } = useMutation(fireMutation, {
onMutate: () => {
queryClient.cancelQueries(queryKey)
const oldData = queryClient.getQueryData(queryKey)
return oldData
},
onError: (err, _, oldData) => {
toast({ type: 'error', content: '请重试', autoHide: false })
queryClient.setQueryData(queryKey, oldData)
onSettled: () => {
queryClient.invalidateQueries(queryKey)
}
})