From a4aade5a29945f55a12608b43e3e62e9e333fc03 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sun, 4 Jan 2026 23:21:14 +0000 Subject: [PATCH] firmware/actions: remove didStart and didFinish actions Remove didStart and didFinish actions from firmware flashing sagas as they are not used for anything. didFailToFinish is not so easily removed as it is used to trigger error toasts. --- src/firmware/actions.ts | 13 -------- src/firmware/sagas.test.ts | 62 -------------------------------------- src/firmware/sagas.ts | 11 ------- 3 files changed, 86 deletions(-) diff --git a/src/firmware/actions.ts b/src/firmware/actions.ts index 5dff5c99..77d1929d 100644 --- a/src/firmware/actions.ts +++ b/src/firmware/actions.ts @@ -132,19 +132,6 @@ export const flashFirmware = createAction( }), ); -/** - * Action that indicates flashing firmware started. - * @param total The total number of bytes to be flashed. - */ -export const didStart = createAction(() => ({ - type: 'flashFirmware.action.didStart', -})); - -/** Action that indicates that flashing firmware completed successfully. */ -export const didFinish = createAction(() => ({ - type: 'flashFirmware.action.didFinish', -})); - // FIXME: get rid of this monstrosity const didFailToFinishType = 'flashFirmware.action.didFailToFinish'; diff --git a/src/firmware/sagas.test.ts b/src/firmware/sagas.test.ts index 97d446a4..5af6da28 100644 --- a/src/firmware/sagas.test.ts +++ b/src/firmware/sagas.test.ts @@ -42,8 +42,6 @@ import { HubError, MetadataProblem, didFailToFinish, - didFinish, - didStart, flashFirmware as flashFirmwareAction, } from './actions'; import flashFirmware from './sagas'; @@ -124,12 +122,6 @@ describe('flashFirmware', () => { const mpyBinaryData = new Uint8Array(mpySize); saga.put(didCompile(mpyBinaryData)); - // then start flashing the firmware - - // should get didStart action just before starting to erase - action = await saga.take(); - expect(action).toEqual(didStart()); - // erase first action = await saga.take(); @@ -232,9 +224,6 @@ describe('flashFirmware', () => { // then we are done - action = await saga.take(); - expect(action).toEqual(didFinish()); - await saga.end(); }); @@ -284,12 +273,6 @@ describe('flashFirmware', () => { saga.put(didRequest(0)); saga.put(infoResponse(0x01000000, 0x08005000, 0x081f800, HubType.MoveHub)); - // then start flashing the firmware - - // should get didStart action just before starting to erase - action = await saga.take(); - expect(action).toEqual(didStart()); - // erase first action = await saga.take(); @@ -392,9 +375,6 @@ describe('flashFirmware', () => { // then we are done - action = await saga.take(); - expect(action).toEqual(didFinish()); - await saga.end(); }); @@ -1008,12 +988,6 @@ describe('flashFirmware', () => { const mpyBinaryData = new Uint8Array(mpySize); saga.put(didCompile(mpyBinaryData)); - // then start flashing the firmware - - // should get didStart action just before starting to erase - action = await saga.take(); - expect(action).toEqual(didStart()); - // erase first action = await saga.take(); @@ -1121,12 +1095,6 @@ describe('flashFirmware', () => { const mpyBinaryData = new Uint8Array(mpySize); saga.put(didCompile(mpyBinaryData)); - // then start flashing the firmware - - // should get didStart action just before starting to erase - action = await saga.take(); - expect(action).toEqual(didStart()); - // erase first action = await saga.take(); @@ -1243,12 +1211,6 @@ describe('flashFirmware', () => { const mpyBinaryData = new Uint8Array(mpySize); saga.put(didCompile(mpyBinaryData)); - // then start flashing the firmware - - // should get didStart action just before starting to erase - action = await saga.take(); - expect(action).toEqual(didStart()); - // erase first action = await saga.take(); @@ -1416,12 +1378,6 @@ describe('flashFirmware', () => { const mpyBinaryData = new Uint8Array(mpySize); saga.put(didCompile(mpyBinaryData)); - // then start flashing the firmware - - // should get didStart action just before starting to erase - action = await saga.take(); - expect(action).toEqual(didStart()); - // erase first action = await saga.take(); @@ -1594,12 +1550,6 @@ describe('flashFirmware', () => { saga.put(didRequest(0)); saga.put(infoResponse(0x01000000, 0x08005000, 0x081f800, HubType.MoveHub)); - // then start flashing the firmware - - // should get didStart action just before starting to erase - action = await saga.take(); - expect(action).toEqual(didStart()); - // erase first action = await saga.take(); @@ -1703,9 +1653,6 @@ describe('flashFirmware', () => { // then we are done - action = await saga.take(); - expect(action).toEqual(didFinish()); - await saga.end(); }); @@ -2156,12 +2103,6 @@ describe('flashFirmware', () => { const mpyBinaryData = new Uint8Array(mpySize); saga.put(didCompile(mpyBinaryData)); - // then start flashing the firmware - - // should get didStart action just before starting to erase - action = await saga.take(); - expect(action).toEqual(didStart()); - // erase first action = await saga.take(); @@ -2262,9 +2203,6 @@ describe('flashFirmware', () => { // then we are done - action = await saga.take(); - expect(action).toEqual(didFinish()); - await saga.end(); }); }); diff --git a/src/firmware/sagas.ts b/src/firmware/sagas.ts index 69a62477..946b1447 100644 --- a/src/firmware/sagas.ts +++ b/src/firmware/sagas.ts @@ -74,8 +74,6 @@ import { HubError, MetadataProblem, didFailToFinish, - didFinish, - didStart, firmwareDidFailToFlashEV3, firmwareDidFailToFlashUsbDfu, firmwareDidFailToRestoreOfficialDfu, @@ -465,8 +463,6 @@ function* handleFlashFirmware(action: ReturnType): Generat } } - yield* put(didStart()); - yield* put( alertsShowAlert( 'firmware', @@ -630,8 +626,6 @@ function* handleFlashFirmware(action: ReturnType): Generat // this will cause the remote device to disconnect and reboot const rebootAction = yield* put(rebootRequest(nextMessageId())); yield* waitForDidRequest(rebootAction.id); - - yield* put(didFinish()); } catch (err) { yield* put(didFailToFinish(FailToFinishReasonType.Unknown, ensureError(err))); yield* disconnectAndCancel(); @@ -1211,9 +1205,6 @@ function* handleFlashEV3(action: ReturnType): Generator return [new DataView(reply.payload), undefined]; } - // FIXME: should be called much earlier. - yield* put(didStart()); - const sectorSize = 64 * 1024; // flash memory sector size const maxPayloadSize = 1018; // maximum payload size for EV3 commands @@ -1288,8 +1279,6 @@ function* handleFlashEV3(action: ReturnType): Generator return; } - yield* put(didFinish()); - yield* cleanup(); yield* put(firmwareDidFlashEV3());