File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { useMockApi } from '~usecases/lib/components/mocks/MockApiProvider';
77import { selectAllFailedTransitions } from '~usecases/lib/store/epics/selectors' ;
88
99/** Retries all failed transitions when coming back online.
10+ * Only fires on the offline → online transition, not while already online.
1011 * The `retry` callback is pattern-specific:
1112 * - Basic/Thunks: routes each action to the correct handler/thunk
1213 * - Sagas: re-dispatches the stage action (saga watcher picks it up) */
@@ -16,7 +17,12 @@ export const useAutoRetry = (retry: (action: StagedAction) => void) => {
1617 const retryRef = useRef ( retry ) ;
1718 retryRef . current = retry ;
1819
20+ const wasOnline = useRef ( online ) ;
21+
1922 useEffect ( ( ) => {
20- if ( online ) failedTransitions . forEach ( ( a ) => retryRef . current ( a ) ) ;
23+ if ( online && ! wasOnline . current ) {
24+ failedTransitions . forEach ( ( a ) => retryRef . current ( a ) ) ;
25+ }
26+ wasOnline . current = online ;
2127 } , [ online , failedTransitions ] ) ;
2228} ;
You can’t perform that action at this time.
0 commit comments