Fix connection mutation delays: make all onSuccess fire-and-forget
sendRequestMutation and cancelMutation were awaiting query invalidation in onSuccess, which blocked mutateAsync until 3+ network refetches completed (~1s+ delay). This caused noticeable lag on send/link/cancel operations. Now all mutations use sync fire-and-forget invalidation, matching respondMutation's pattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
dff36f30c8
commit
6b59d61bf3
@ -47,8 +47,9 @@ export function useConnections() {
|
|||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
onSuccess: async () => {
|
onSuccess: () => {
|
||||||
await queryClient.invalidateQueries({ queryKey: ['connections'] });
|
// Fire-and-forget — don't block mutateAsync on query refetches
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['connections'] });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,11 +73,10 @@ export function useConnections() {
|
|||||||
const { data } = await api.put(`/connections/requests/${requestId}/cancel`);
|
const { data } = await api.put(`/connections/requests/${requestId}/cancel`);
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
onSuccess: async () => {
|
onSuccess: () => {
|
||||||
await Promise.all([
|
// Fire-and-forget — don't block mutateAsync on query refetches
|
||||||
queryClient.invalidateQueries({ queryKey: ['connections'] }),
|
queryClient.invalidateQueries({ queryKey: ['connections'] });
|
||||||
queryClient.invalidateQueries({ queryKey: ['notifications'] }),
|
queryClient.invalidateQueries({ queryKey: ['notifications'] });
|
||||||
]);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user