Skip to content

Commit acb4ceb

Browse files
committed
Merge remote-tracking branch 'origin/master' into network-retries
2 parents 197b57e + 93caaf0 commit acb4ceb

File tree

2 files changed

+61
-61
lines changed

2 files changed

+61
-61
lines changed

src/app/Flash.jsx

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useRef, useState } from 'react'
22

3-
import { FlashManager, Step, Error } from '../utils/manager'
3+
import { FlashManager, StepCode, ErrorCode } from '../utils/manager'
44
import { useImageManager } from '../utils/image'
55
import { isLinux } from '../utils/platform'
66
import config from '../config'
@@ -15,48 +15,48 @@ import systemUpdate from '../assets/system_update_c3.svg'
1515

1616

1717
const steps = {
18-
[Step.INITIALIZING]: {
18+
[StepCode.INITIALIZING]: {
1919
status: 'Initializing...',
2020
bgColor: 'bg-gray-400 dark:bg-gray-700',
2121
icon: bolt,
2222
},
23-
[Step.READY]: {
23+
[StepCode.READY]: {
2424
status: 'Tap to start',
2525
bgColor: 'bg-[#51ff00]',
2626
icon: bolt,
2727
iconStyle: '',
2828
},
29-
[Step.CONNECTING]: {
29+
[StepCode.CONNECTING]: {
3030
status: 'Waiting for connection',
3131
description: 'Follow the instructions to connect your device to your computer',
3232
bgColor: 'bg-yellow-500',
3333
icon: cable,
3434
},
35-
[Step.REPAIR_PARTITION_TABLES]: {
35+
[StepCode.REPAIR_PARTITION_TABLES]: {
3636
status: 'Repairing partition tables...',
3737
description: 'Do not unplug your device until the process is complete',
3838
bgColor: 'bg-lime-400',
3939
icon: systemUpdate,
4040
},
41-
[Step.ERASE_DEVICE]: {
41+
[StepCode.ERASE_DEVICE]: {
4242
status: 'Erasing device...',
4343
description: 'Do not unplug your device until the process is complete',
4444
bgColor: 'bg-lime-400',
4545
icon: systemUpdate,
4646
},
47-
[Step.FLASH_SYSTEM]: {
47+
[StepCode.FLASH_SYSTEM]: {
4848
status: 'Flashing device...',
4949
description: 'Do not unplug your device until the process is complete',
5050
bgColor: 'bg-lime-400',
5151
icon: systemUpdate,
5252
},
53-
[Step.FINALIZING]: {
53+
[StepCode.FINALIZING]: {
5454
status: 'Finalizing...',
5555
description: 'Do not unplug your device until the process is complete',
5656
bgColor: 'bg-lime-400',
5757
icon: systemUpdate,
5858
},
59-
[Step.DONE]: {
59+
[StepCode.DONE]: {
6060
status: 'Done',
6161
description: 'Your device was flashed successfully. It should now boot into the openpilot setup.',
6262
bgColor: 'bg-green-500',
@@ -65,46 +65,46 @@ const steps = {
6565
}
6666

6767
const errors = {
68-
[Error.UNKNOWN]: {
68+
[ErrorCode.UNKNOWN]: {
6969
status: 'Unknown error',
7070
description: 'An unknown error has occurred. Unplug your device, restart your browser and try again.',
7171
bgColor: 'bg-red-500',
7272
icon: exclamation,
7373
},
74-
[Error.REQUIREMENTS_NOT_MET]: {
74+
[ErrorCode.REQUIREMENTS_NOT_MET]: {
7575
status: 'Requirements not met',
7676
description: 'Your system does not meet the requirements to flash your device. Make sure to use a browser which ' +
7777
'supports WebUSB and is up to date.',
7878
},
79-
[Error.STORAGE_SPACE]: {
79+
[ErrorCode.STORAGE_SPACE]: {
8080
description: 'Your system does not have enough space available to download AGNOS. Your browser may be restricting' +
8181
' the available space if you are in a private, incognito or guest session.',
8282
},
83-
[Error.UNRECOGNIZED_DEVICE]: {
83+
[ErrorCode.UNRECOGNIZED_DEVICE]: {
8484
status: 'Unrecognized device',
8585
description: 'The device connected to your computer is not supported. Try using a different cable, USB port, or ' +
8686
'computer. If the problem persists, join the #hw-three-3x channel on Discord for help.',
8787
bgColor: 'bg-yellow-500',
8888
icon: deviceQuestion,
8989
},
90-
[Error.LOST_CONNECTION]: {
90+
[ErrorCode.LOST_CONNECTION]: {
9191
status: 'Lost connection',
9292
description: 'The connection to your device was lost. Unplug your device and try again.',
9393
icon: cable,
9494
},
95-
[Error.REPAIR_PARTITION_TABLES_FAILED]: {
95+
[ErrorCode.REPAIR_PARTITION_TABLES_FAILED]: {
9696
status: 'Repairing partition tables failed',
9797
description: 'Your device\'s partition tables could not be repaired. Try using a different cable, USB port, or ' +
9898
'computer. If the problem persists, join the #hw-three-3x channel on Discord for help.',
9999
icon: deviceExclamation,
100100
},
101-
[Error.ERASE_FAILED]: {
101+
[ErrorCode.ERASE_FAILED]: {
102102
status: 'Erase failed',
103103
description: 'The device could not be erased. Try using a different cable, USB port, or computer. If the problem ' +
104104
'persists, join the #hw-three-3x channel on Discord for help.',
105105
icon: deviceExclamation,
106106
},
107-
[Error.FLASH_SYSTEM_FAILED]: {
107+
[ErrorCode.FLASH_SYSTEM_FAILED]: {
108108
status: 'Flash failed',
109109
description: 'AGNOS could not be flashed to your device. Try using a different cable, USB port, or computer. If ' +
110110
'the problem persists, join the #hw-three-3x channel on Discord for help.',
@@ -113,8 +113,8 @@ const errors = {
113113
}
114114

115115
if (isLinux) {
116-
// this is likely in Step.CONNECTING
117-
errors[Error.LOST_CONNECTION].description += ' Did you forget to unbind the device from qcserial?'
116+
// this is likely in StepCode.CONNECTING
117+
errors[ErrorCode.LOST_CONNECTION].description += ' Did you forget to unbind the device from qcserial?'
118118
}
119119

120120

@@ -182,10 +182,10 @@ function beforeUnloadListener(event) {
182182

183183

184184
export default function Flash() {
185-
const [step, setStep] = useState(Step.INITIALIZING)
185+
const [step, setStep] = useState(StepCode.INITIALIZING)
186186
const [message, setMessage] = useState('')
187187
const [progress, setProgress] = useState(-1)
188-
const [error, setError] = useState(Error.NONE)
188+
const [error, setError] = useState(ErrorCode.NONE)
189189
const [connected, setConnected] = useState(false)
190190
const [serial, setSerial] = useState(null)
191191

@@ -215,14 +215,14 @@ export default function Flash() {
215215

216216
// Handle user clicking the start button
217217
const handleStart = () => qdlManager.current?.start()
218-
const canStart = step === Step.READY && !error
218+
const canStart = step === StepCode.READY && !error
219219

220220
// Handle retry on error
221221
const handleRetry = () => window.location.reload()
222222

223223
const uiState = steps[step]
224224
if (error) {
225-
Object.assign(uiState, errors[Error.UNKNOWN], errors[error])
225+
Object.assign(uiState, errors[ErrorCode.UNKNOWN], errors[error])
226226
}
227227
const { status, description, bgColor, icon, iconStyle = 'invert' } = uiState
228228

@@ -232,14 +232,14 @@ export default function Flash() {
232232
if (progress >= 0) {
233233
title += ` (${(progress * 100).toFixed(0)}%)`
234234
}
235-
} else if (error === Error.STORAGE_SPACE) {
235+
} else if (error === ErrorCode.STORAGE_SPACE) {
236236
title = message
237237
} else {
238238
title = status
239239
}
240240

241241
// warn the user if they try to leave the page while flashing
242-
if (step >= Step.FLASH_GPT && step <= Step.FLASH_SYSTEM) {
242+
if (step >= StepCode.FLASH_GPT && step <= StepCode.FLASH_SYSTEM) {
243243
window.addEventListener("beforeunload", beforeUnloadListener, { capture: true })
244244
} else {
245245
window.removeEventListener("beforeunload", beforeUnloadListener, { capture: true })
@@ -257,7 +257,7 @@ export default function Flash() {
257257
alt="cable"
258258
width={128}
259259
height={128}
260-
className={`${iconStyle} ${!error && step !== Step.DONE ? 'animate-pulse' : ''}`}
260+
className={`${iconStyle} ${!error && step !== StepCode.DONE ? 'animate-pulse' : ''}`}
261261
/>
262262
</div>
263263
<div className="w-full max-w-3xl px-8 transition-opacity duration-300" style={{ opacity: progress === -1 ? 0 : 1 }}>

0 commit comments

Comments
 (0)