fix(pending-post): keep retrying failed posts on the pending route (#1161)

* fix(pending-post): keep retrying failed posts on the pending route

Retrying a failed post deletes the pending row before republishing, which
briefly leaves the pending comment non-addressable with no active challenge —
the same state PendingPost's abandoned-challenge guard uses to redirect back to
the board. A shared use-failed-post-retry-store marks the index being retried so
PendingPost skips that redirect until the republished row is created and its own
navigation to the new pending route takes over.

* fix(pending-post): harden retry flag lifecycle against abandoned-challenge race

Address Cursor Bugbot review on the retry flow. Clear the retry flag (and
isRetryRedirectPending) when the republish challenge is abandoned so an abandon
mid-retry falls through to the normal board redirect instead of stranding an
empty pending view. Also navigate to the new pending row before clearing the
flag in the redirect effect so PendingPost never observes an old-index route
with the flag already cleared.
This commit is contained in:
Tommaso Casaburi
2026-06-08 16:08:51 +07:00
committed by GitHub
parent c2b222c4d5
commit bd12b47db6
5 changed files with 122 additions and 7 deletions
+19
View File
@@ -0,0 +1,19 @@
import { create } from 'zustand';
interface FailedPostRetryState {
// Account-comment index of the failed post currently being retried, or null when no retry is in flight.
// Retrying deletes the old pending row and republishes, so the pending route briefly has no addressable
// comment and no active challenge. The pending view reads this to avoid mistaking that gap for an
// abandoned challenge and redirecting away.
retryingAccountCommentIndex: number | null;
startRetry: (accountCommentIndex: number) => void;
endRetry: () => void;
}
const useFailedPostRetryStore = create<FailedPostRetryState>((set) => ({
retryingAccountCommentIndex: null,
startRetry: (accountCommentIndex) => set({ retryingAccountCommentIndex: accountCommentIndex }),
endRetry: () => set({ retryingAccountCommentIndex: null }),
}));
export default useFailedPostRetryStore;