diff --git a/src/store/flash.ts b/src/store/flash.ts index 5efdb7cf..d9789ba8 100644 --- a/src/store/flash.ts +++ b/src/store/flash.ts @@ -35,7 +35,12 @@ export const useFlashStore = defineStore("flash", { }, fetchRuntimeConfig(target: string) { return fetch(TARGET_URL + target + ".yaml") - .then((res) => res.text()) + .then((res) => { + if (!res.ok) { + return Promise.reject(res); + } + return res.text(); + }) .then((res) => YAML.parse(res)) .then((target) => CBOR.encode(target)); }, diff --git a/src/views/Flash.vue b/src/views/Flash.vue index 65fb10ba..a8128b27 100644 --- a/src/views/Flash.vue +++ b/src/views/Flash.vue @@ -274,7 +274,7 @@ export default defineComponent({ { value: "branch", text: "Development Branch" }, { value: "local", text: "Local" }, ], - progress: {}, + progress: [] as any[], source: "release", release: undefined as string | undefined, branch: undefined as string | undefined, @@ -443,14 +443,17 @@ export default defineComponent({ const flasher = new Flasher(); flasher.onProgress((p) => this.updateProgress(p)); - this.updateProgress({ - task: "download", - current: 10, - total: 100, - }); - - return Promise.all([this.fetchFirmware(), flasher.connect()]) - .then(async ([hexStr]) => { + return flasher + .connect() + .then(() => { + this.updateProgress({ + task: "download", + current: 10, + total: 100, + }); + return this.fetchFirmware(); + }) + .then(async (hexStr) => { if (!hexStr) { throw new Error("firmware not found"); } @@ -492,7 +495,7 @@ export default defineComponent({ }); }) .finally(() => { - this.progress = {}; + this.progress = []; this.loading = false; }); },