fix(amber): serialize Cordn setup and explain the two approvals
This commit is contained in:
parent
8a347b4435
commit
68b77d6c14
2 changed files with 22 additions and 0 deletions
|
|
@ -884,6 +884,20 @@ export function CordnNativePanel({
|
||||||
{copy.encryptedNote}
|
{copy.encryptedNote}
|
||||||
</p>
|
</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">
|
<div className="flex flex-wrap items-center justify-center gap-2">
|
||||||
{canCreate ? (
|
{canCreate ? (
|
||||||
<Button
|
<Button
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,14 @@ export function useCordnNative({
|
||||||
return () => clearInterval(id);
|
return () => clearInterval(id);
|
||||||
}, [ready, group, interactive, canBackgroundPoll, refresh]);
|
}, [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> => {
|
const run = useCallback(async <T,>(fn: () => Promise<T>): Promise<T | undefined> => {
|
||||||
|
if (runInFlight.current) return undefined;
|
||||||
|
runInFlight.current = true;
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
|
|
@ -265,6 +272,7 @@ export function useCordnNative({
|
||||||
setError(err instanceof Error ? err.message : String(err));
|
setError(err instanceof Error ? err.message : String(err));
|
||||||
return undefined;
|
return undefined;
|
||||||
} finally {
|
} finally {
|
||||||
|
runInFlight.current = false;
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
setLastCheckedAt(Date.now());
|
setLastCheckedAt(Date.now());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue