Skip to content

Commit d460d77

Browse files
committed
update platform functions
1 parent a7b357a commit d460d77

File tree

2 files changed

+6
-34
lines changed

2 files changed

+6
-34
lines changed

src/lib/components/Flash.svelte

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,7 @@
1414
import exclamation from "$lib/images/exclamation.svg";
1515
import systemUpdate from "$lib/images/system_update_c3.svg";
1616
17-
let isLinux = false;
18-
19-
if (browser) {
20-
let userAgent = "";
21-
if ('userAgentData' in globalThis.navigator && 'platform' in globalThis.navigator.userAgentData && globalThis.navigator.userAgentData.platform) {
22-
userAgent = globalThis.navigator.userAgentData.platform
23-
} else {
24-
userAgent = globalThis.navigator.userAgent.toLowerCase()
25-
}
26-
if (userAgent.includes('linux')) {
27-
isLinux = true;
28-
} else if (userAgent.includes('win32') || userAgent.includes('windows')) {
29-
isWindows = true;
30-
}
31-
}
17+
let isLinux = () => globalThis.navigator.userAgent.toLowerCase().includes("linux") ?? false;
3218
3319
const steps = {
3420
[StepCode.INITIALIZING]: {
@@ -136,7 +122,7 @@
136122
},
137123
};
138124
139-
if (isLinux) {
125+
if (isLinux()) {
140126
// this is likely in StepCode.CONNECTING
141127
errors[ErrorCode.LOST_CONNECTION].description +=
142128
" Did you forget to unbind the device from qcserial?";

src/routes/+page.svelte

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,8 @@
1010
import Flash from "$lib/components/Flash.svelte";
1111
import CopyText from "$lib/components/CopyText.svelte";
1212
13-
let isLinux = $state(false);
14-
let isWindows = $state(false);
15-
16-
if (browser) {
17-
let userAgent = "";
18-
if ('userAgentData' in globalThis.navigator && 'platform' in globalThis.navigator.userAgentData && globalThis.navigator.userAgentData.platform) {
19-
userAgent = globalThis.navigator.userAgentData.platform
20-
} else {
21-
userAgent = globalThis.navigator.userAgent.toLowerCase()
22-
}
23-
if (userAgent.includes('linux')) {
24-
isLinux = true;
25-
} else if (userAgent.includes('win32') || userAgent.includes('windows')) {
26-
isWindows = true;
27-
}
28-
}
13+
let isLinux = () => globalThis.navigator.userAgent.toLowerCase().includes("linux") ?? false;
14+
let isWindows = () => globalThis.navigator.userAgent.toLowerCase().includes("windows") ?? false;
2915
3016
const VENDOR_ID = "05C6";
3117
const PRODUCT_ID = "9008";
@@ -80,7 +66,7 @@
8066
</li>
8167
</ul>
8268
{#if browser}
83-
{#if isWindows}
69+
{#if isWindows()}
8470
<h3>USB Driver</h3>
8571
<p>
8672
You need additional driver software for Windows before you connect your device.
@@ -145,7 +131,7 @@
145131
Your device&apos;s screen will remain blank for the entire flashing process. This is normal.
146132
</p>
147133
{#if browser}
148-
{#if isLinux}
134+
{#if isLinux()}
149135
<strong>Note for Linux users</strong>
150136
<p>
151137
On Linux systems, devices in QDL mode are automatically bound to the kernel&apos;s qcserial driver, and need

0 commit comments

Comments
 (0)