fix(amber): serialize Cordn setup and explain the two approvals

This commit is contained in:
SkateSpots 2026-10-30 10:25:04 +07:00
parent 8a347b4435
commit 68b77d6c14
2 changed files with 22 additions and 0 deletions

View file

@ -884,6 +884,20 @@ export function CordnNativePanel({
{copy.encryptedNote}
</p>
{/* Amber needs one foreground approval for the device key and one
for the join request. Show the two translated step labels so the
second prompt is expected, not a mystery. */}
{native.interactiveHintVisible && !canCreate && (
<p className="mx-auto flex max-w-sm items-center justify-center gap-1.5 text-[11px] text-amber-300/80">
<KeyRound className="h-3 w-3 shrink-0" />
<span>Amber</span>
<span aria-hidden="true">·</span>
<span>{t('cordnUi.setupDevice')}</span>
<span aria-hidden="true">→</span>
<span>{t('cordnUi.requestJoin')}</span>
</p>
)}
<div className="flex flex-wrap items-center justify-center gap-2">
{canCreate ? (
<Button

View file

@ -256,7 +256,14 @@ export function useCordnNative({
return () => clearInterval(id);
}, [ready, group, interactive, canBackgroundPoll, refresh]);
// One coordinator operation at a time. With Amber every coordinator request
// is a foreground approval; a double-tap on "Set up" used to start two
// publish/join flows, which looked like Amber randomly opening twice and left
// one of the two requests to time out.
const runInFlight = useRef(false);
const run = useCallback(async <T,>(fn: () => Promise<T>): Promise<T | undefined> => {
if (runInFlight.current) return undefined;
runInFlight.current = true;
setBusy(true);
setError(null);
try {
@ -265,6 +272,7 @@ export function useCordnNative({
setError(err instanceof Error ? err.message : String(err));
return undefined;
} finally {
runInFlight.current = false;
setBusy(false);
setLastCheckedAt(Date.now());
}