Skip to content

Commit bcd9e55

Browse files
committed
Code cleaning
1 parent 15e84cb commit bcd9e55

File tree

4 files changed

+6
-37
lines changed

4 files changed

+6
-37
lines changed

src/App.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import BottomBarMenuView from './views/BottomBarMenuView.svelte';
3030
import CookieBanner from './components/cookie-bannner/CookieBanner.svelte';
3131
import { fade } from 'svelte/transition';
32-
import { compatibility, state } from './script/stores/uiStore';
32+
import { state } from './script/stores/uiStore';
3333
import LoadingSpinner from './components/LoadingSpinner.svelte';
3434
import { checkCompatibility } from './script/compatibility/CompatibilityChecker';
3535
import IncompatiblePlatformView from './views/IncompatiblePlatformView.svelte';

src/components/connection-prompt/usb/FindUsbDialog.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
function onFindUsbClick() {
1010
Microbits.linkMicrobit()
1111
.then(() => onFoundUsb())
12-
.catch(() => {
12+
.catch((e: Error) => {
13+
console.log(e)
1314
onUsbLinkError();
1415
});
1516
}

src/script/compatibility/CompatibilityChecker.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ export type CompatibilityStatus = {
1313
usb: boolean;
1414
platformAllowed: boolean;
1515
webGL: boolean,
16-
webUSB: boolean
1716
};
1817

1918
export function checkCompatibility(): CompatibilityStatus {
2019
if (localStorage.getItem('isTesting')) {
21-
return { bluetooth: true, usb: true, platformAllowed: true, webGL: true, webUSB: true };
20+
return { bluetooth: true, usb: true, platformAllowed: true, webGL: true };
2221
}
2322
const browser = Bowser.getParser(window.navigator.userAgent);
2423
const browserName = browser.getBrowser().name ?? 'unknown';
@@ -28,17 +27,9 @@ export function checkCompatibility(): CompatibilityStatus {
2827
// TODO: Handle webgl1 vs webgl2 in relation to threejs
2928
const webGL = canvas.getContext("webgl") instanceof WebGLRenderingContext
3029

31-
const webUSB = false // Check for this is async, so another function is used
32-
// try {
33-
// await navigator.usb.getDevices()
34-
// webUSB = true
35-
// } catch {
36-
// webUSB = false
37-
// }
38-
3930
const browserVersion = browser.getBrowserVersion();
4031
if (!browserVersion) {
41-
return { bluetooth: false, usb: false, platformAllowed: true, webGL: webGL, webUSB };
32+
return { bluetooth: false, usb: false, platformAllowed: true, webGL: webGL };
4233
}
4334
const majorVersion = browser.getBrowserVersion().split('.')[0];
4435
const minorVersion = browser.getBrowserVersion().split('.')[1];
@@ -60,18 +51,6 @@ export function checkCompatibility(): CompatibilityStatus {
6051
usb: isUsbSupported,
6152
platformAllowed: isPlatformAllowed,
6253
webGL: webGL,
63-
webUSB: webUSB
6454
};
6555
}
6656

67-
export async function checkUSBCompatibility(): Promise<boolean> {
68-
try {
69-
await navigator.usb.getDevices()
70-
return true
71-
} catch {
72-
return false
73-
}
74-
}
75-
// }
76-
77-
// export default CompatibilityChecker;

src/script/stores/uiStore.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { get, writable } from 'svelte/store';
2-
import {
3-
type CompatibilityStatus,
4-
checkCompatibility,
5-
checkUSBCompatibility
6-
} from '../compatibility/CompatibilityChecker';
2+
import { type CompatibilityStatus, checkCompatibility} from '../compatibility/CompatibilityChecker';
73
import { t } from '../../i18n';
84
import { gestures } from './mlStore';
95
import { DeviceRequestStates } from './connectDialogStore';
@@ -17,13 +13,6 @@ export const compatibility = writable<CompatibilityStatus>(
1713
checkCompatibility(),
1814
);
1915

20-
void checkUSBCompatibility().then(webUSB =>
21-
compatibility.update(old => {
22-
old.webUSB = webUSB
23-
return old
24-
})
25-
)
26-
2716
export const isBluetoothWarningDialogOpen = writable<boolean>(
2817
get(compatibility) ? !get(compatibility).bluetooth : false,
2918
);

0 commit comments

Comments
 (0)