Skip to content

Commit 673712e

Browse files
srietkerkthsparks
andauthored
add a default option to the cannot pair dialog (microsoft#10432)
* add a default option to the cannot pair dialog * open the hw dialog if a webusb device has not been selected to connect * keeping isarcade check separate from the reasonunsupported switch statement * make the changes so the behavior is close to live * update the default message Co-authored-by: Thomas Sparks <[email protected]> --------- Co-authored-by: Thomas Sparks <[email protected]>
1 parent f63cd39 commit 673712e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pxtlib/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ namespace pxt {
339339
})
340340
}
341341

342+
export function getActiveHwVariant(): string {
343+
return hwVariant
344+
}
345+
342346
export interface PxtOptions {
343347
debug?: boolean;
344348
light?: boolean; // low resource device

webapp/src/editortoolbar.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export class EditorToolbar extends data.Component<ISettingsProps, EditorToolbarS
211211
protected onCannotPairClick = async () => {
212212
pxt.tickEvent("editortools.pairunsupported", undefined, { interactiveConsent: true });
213213
const reasonUnsupported = await pxt.usb.getReasonUnavailable();
214+
214215
let modalBody: string;
215216
switch (reasonUnsupported) {
216217
case "security":
@@ -225,6 +226,9 @@ export class EditorToolbar extends data.Component<ISettingsProps, EditorToolbarS
225226
case "notimpl":
226227
modalBody = lf("WebUSB is not supported by this browser; please check for updates.");
227228
break;
229+
default:
230+
modalBody = lf("Unable to connect to WebUSB. Please try refreshing the page.");
231+
break;
228232
}
229233

230234
dialogAsync({
@@ -275,9 +279,11 @@ export class EditorToolbar extends data.Component<ISettingsProps, EditorToolbarS
275279

276280
const boards = pxt.appTarget.simulator && !!pxt.appTarget.simulator.dynamicBoardDefinition;
277281
const editorSupportsWebUSB = pxt.appTarget?.compile?.webUSB;
282+
const hardwareVariantSelected = (pxt.appTarget.alwaysMultiVariant || !pxt.appTarget.variants || !!(pxt.getActiveHwVariant()))
278283
const webUSBSupported = pxt.usb.isEnabled && editorSupportsWebUSB;
279284
const showUsbNotSupportedHint = editorSupportsWebUSB
280285
&& !pxt.usb.isEnabled
286+
&& hardwareVariantSelected
281287
&& pxt.shell.getControllerMode() !== pxt.shell.ControllerMode.App
282288
&& !pxt.BrowserUtils.isPxtElectron()
283289
&& (pxt.BrowserUtils.isChromiumEdge() || pxt.BrowserUtils.isChrome());

0 commit comments

Comments
 (0)