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:
Matthew Meszaros
2026-09-08 08:34:20 -07:00
parent 073bb3c6bc
commit c35495ae5c
@@ -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] });
});
};