mirror of
https://github.com/warmbly/warmbly.git
synced 2026-09-10 00:04:27 +00:00
feat: await the trigger card's recovery refetch inside the same promise chain as its saves, so a refused entry-delay commit's invalidation cannot resolve after the next commit's optimistic write and put the stale delay back on the card
This commit is contained in:
@@ -461,11 +461,14 @@ function TriggerNode({ data }: NodeProps) {
|
||||
inFlight.current = inFlight.current
|
||||
.catch(() => {})
|
||||
.then(() => updateCampaign.mutateAsync({ entry_delay_minutes: next }))
|
||||
.catch((err) => {
|
||||
.catch(async (err) => {
|
||||
toast.error(buildError(err as AppError));
|
||||
// Put the optimistic value back where the server left it, so a
|
||||
// refused save does not leave the card claiming a delay it never got.
|
||||
void qc.invalidateQueries({ queryKey: ["campaigns", campaignId] });
|
||||
// refused save does not leave the card claiming a delay it never
|
||||
// got. Awaited so the recovery refetch stays INSIDE the chain: a
|
||||
// detached one could land after the next commit's optimistic
|
||||
// write and put the stale value back on the card.
|
||||
await qc.invalidateQueries({ queryKey: ["campaigns", campaignId] });
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user