fix(cordn): keep the invite poll alive across re-renders
This commit is contained in:
parent
7a7b1c4950
commit
5ac9e67860
1 changed files with 9 additions and 2 deletions
|
|
@ -214,6 +214,13 @@ export function CordnNativePanel({ crew, canManage, isMember }: CordnNativePanel
|
|||
if (!awaiting) setNotice(t('cordnUi.noInvite'));
|
||||
}, [checkNow, awaiting, t, native.busy]);
|
||||
|
||||
// Keep the latest checker in a ref: the poll must not restart just because a
|
||||
// parent re-render gave the hook callbacks new identities.
|
||||
const checkNowRef = useRef(checkNow);
|
||||
useEffect(() => {
|
||||
checkNowRef.current = checkNow;
|
||||
}, [checkNow]);
|
||||
|
||||
// Poll the coordinator while a join request is pending. Backs off from 10s to
|
||||
// 30s so a founder who approves later is picked up without a manual tap.
|
||||
// Interactive signers (Amber) are excluded — polling would pop their signer.
|
||||
|
|
@ -225,7 +232,7 @@ export function CordnNativePanel({ crew, canManage, isMember }: CordnNativePanel
|
|||
|
||||
const tick = async () => {
|
||||
if (cancelled) return;
|
||||
const joined = await checkNow();
|
||||
const joined = await checkNowRef.current();
|
||||
if (cancelled) return;
|
||||
if (joined) {
|
||||
setAwaiting(false);
|
||||
|
|
@ -241,7 +248,7 @@ export function CordnNativePanel({ crew, canManage, isMember }: CordnNativePanel
|
|||
cancelled = true;
|
||||
if (timer !== undefined) window.clearTimeout(timer);
|
||||
};
|
||||
}, [awaiting, native.group, native.ready, native.interactiveHintVisible, checkNow]);
|
||||
}, [awaiting, native.group, native.ready, native.interactiveHintVisible]);
|
||||
|
||||
// "Join our crew chat" invite. The chat needs the person to be a crew member
|
||||
// first, so the link just drops them on this crew's private-chat tab with the
|
||||
|
|
|
|||
Loading…
Reference in a new issue