Skip to content

Commit 199302a

Browse files
Only show dialog overlay for request device prompt (#216)
This avoids the user clicking through to "next" triggering a new call to request device while the select device prompt is already up.
1 parent d4725fd commit 199302a

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/components/connection-prompt/ConnectDialogContainer.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@
104104
};
105105
106106
async function tryMicrobitUSBConnection(): Promise<void> {
107+
$connectionDialogState.connectionState = ConnectDialogStates.BROWSER_DIALOG;
107108
let usb: MicrobitUSB | undefined;
108109
try {
109110
usb = await MicrobitUSB.requestConnection();
110111
} catch (err) {
111-
handleConnectionError(err);
112-
return;
112+
return handleConnectionError(err);
113113
}
114114
return flashMicrobit(usb);
115115
}
@@ -215,6 +215,8 @@
215215

216216
<div bind:this={dialogContainer}>
217217
<StandardDialog
218+
hideContent={$connectionDialogState.connectionState ===
219+
ConnectDialogStates.BROWSER_DIALOG}
218220
isOpen={$connectionDialogState.connectionState !== ConnectDialogStates.NONE &&
219221
!endOfFlow}
220222
onClose={connectionStateNone}

src/components/dialogs/StandardDialog.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
export let closeOnEscape: boolean = true;
1919
export let isOpen: boolean;
2020
export let onClose: () => void;
21+
export let hideContent: boolean = false;
2122
2223
let finalFocusRef: Element | null;
2324
@@ -90,6 +91,7 @@
9091
<div
9192
use:melt={$content}
9293
class="w-min h-min border-gray-200 border border-solid relative bg-white rounded-lg p-8 z-15"
94+
class:hidden={hideContent}
9395
transition:scale={{
9496
duration: 200,
9597
start: 0.9,

src/script/stores/connectDialogStore.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export enum ConnectDialogStates {
2727
MANUAL_TUTORIAL, // Prompt with tutorial gif for manual installation (and downloading of program)
2828
USB_TRY_AGAIN, // Prompt user to try connecting via WebUSB again
2929
BLUETOOTH_TRY_AGAIN, // Prompt user to try connecting via WebBluetooth again
30+
BROWSER_DIALOG, // Awaiting user interaction with browser dialog
3031
}
3132

3233
export const connectionDialogState = writable<{

0 commit comments

Comments
 (0)