firmware: remove progress/didProgress

Remove the didProgress action and progress state, as they were not being used.
This commit is contained in:
David Lechner
2026-01-03 21:01:53 -06:00
parent 4469e173cd
commit 830855e428
5 changed files with 4 additions and 74 deletions
+1 -10
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2020-2025 The Pybricks Authors
// Copyright (c) 2020-2026 The Pybricks Authors
import { FirmwareReaderError, HubType } from '@pybricks/firmware';
import { createAction } from '../actions';
@@ -139,15 +139,6 @@ export const didStart = createAction(() => ({
type: 'flashFirmware.action.didStart',
}));
/**
* Action that indicates current firmware flashing progress.
* @param value The current progress (0 to 1).
*/
export const didProgress = createAction((value: number) => {
// assert(value >= 0 && value <= 1, 'value out of range');
return { type: 'flashFirmware.action.didProgress', value };
});
/** Action that indicates that flashing firmware completed successfully. */
export const didFinish = createAction(() => ({
type: 'flashFirmware.action.didFinish',
+1 -8
View File
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2021-2025 The Pybricks Authors
// Copyright (c) 2021-2026 The Pybricks Authors
import { AnyAction } from 'redux';
import {
FailToFinishReasonType,
didFailToFinish,
didFinish,
didProgress,
didStart,
} from './actions';
import reducers from './reducers';
@@ -26,7 +25,6 @@ test('initial state', () => {
"isFirmwareFlashEV3InProgress": false,
"isFirmwareFlashUsbDfuInProgress": false,
"isFirmwareRestoreOfficialDfuInProgress": false,
"progress": null,
"restoreOfficialDialog": {
"isOpen": false,
},
@@ -44,8 +42,3 @@ test('flashing', () => {
).flashing,
).toBe(false);
});
test('progress', () => {
expect(reducers({ progress: 1 } as State, didStart()).progress).toBe(null);
expect(reducers({ progress: null } as State, didProgress(1)).progress).toBe(1);
});
+1 -15
View File
@@ -1,11 +1,10 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2021-2025 The Pybricks Authors
// Copyright (c) 2021-2026 The Pybricks Authors
import { Reducer, combineReducers } from 'redux';
import {
didFailToFinish,
didFinish,
didProgress,
didStart,
firmwareDidFailToFlashUsbDfu,
firmwareDidFailToRestoreOfficialDfu,
@@ -33,18 +32,6 @@ const flashing: Reducer<boolean> = (state = false, action) => {
return state;
};
const progress: Reducer<number | null> = (state = null, action) => {
if (didStart.matches(action)) {
return null;
}
if (didProgress.matches(action)) {
return action.value;
}
return state;
};
const isFirmwareFlashUsbDfuInProgress: Reducer<boolean> = (state = false, action) => {
if (firmwareFlashUsbDfu.matches(action)) {
return true;
@@ -100,7 +87,6 @@ export default combineReducers({
installPybricksDialog,
restoreOfficialDialog,
flashing,
progress,
isFirmwareFlashUsbDfuInProgress,
isFirmwareRestoreOfficialDfuInProgress,
isFirmwareFlashEV3InProgress,
+1 -32
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2021-2024 The Pybricks Authors
// Copyright (c) 2021-2026 The Pybricks Authors
import {
FirmwareMetadata,
@@ -43,7 +43,6 @@ import {
MetadataProblem,
didFailToFinish,
didFinish,
didProgress,
didStart,
flashFirmware as flashFirmwareAction,
} from './actions';
@@ -175,9 +174,6 @@ describe('flashFirmware', () => {
saga.put(didRequest(id));
action = await saga.take();
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
action = await saga.take();
expect(action).toEqual(
alertsShowAlert(
@@ -213,9 +209,6 @@ describe('flashFirmware', () => {
saga.put(programResponse(0x33, totalFirmwareSize));
action = await saga.take();
expect(action).toEqual(didProgress(1));
action = await saga.take();
expect(action).toEqual(
alertsShowAlert(
@@ -341,9 +334,6 @@ describe('flashFirmware', () => {
saga.put(didRequest(id));
action = await saga.take();
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
action = await saga.take();
expect(action).toEqual(
alertsShowAlert(
@@ -379,9 +369,6 @@ describe('flashFirmware', () => {
saga.put(programResponse(0xe0, totalFirmwareSize));
action = await saga.take();
expect(action).toEqual(didProgress(1));
action = await saga.take();
expect(action).toEqual(
alertsShowAlert(
@@ -1306,9 +1293,6 @@ describe('flashFirmware', () => {
saga.put(didRequest(id));
action = await saga.take();
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
action = await saga.take();
expect(action).toEqual(
alertsShowAlert(
@@ -1482,9 +1466,6 @@ describe('flashFirmware', () => {
saga.put(didRequest(id));
action = await saga.take();
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
action = await saga.take();
expect(action).toEqual(
alertsShowAlert(
@@ -1664,9 +1645,6 @@ describe('flashFirmware', () => {
saga.put(didRequest(id));
action = await saga.take();
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
action = await saga.take();
expect(action).toEqual(
alertsShowAlert(
@@ -1702,9 +1680,6 @@ describe('flashFirmware', () => {
saga.put(programResponse(0xf3, totalFirmwareSize));
action = await saga.take();
expect(action).toEqual(didProgress(1));
action = await saga.take();
expect(action).toEqual(
alertsShowAlert(
@@ -2230,9 +2205,6 @@ describe('flashFirmware', () => {
saga.put(didRequest(id));
action = await saga.take();
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
action = await saga.take();
expect(action).toEqual(
alertsShowAlert(
@@ -2267,9 +2239,6 @@ describe('flashFirmware', () => {
saga.put(programResponse(0x27, totalFirmwareSize));
action = await saga.take();
expect(action).toEqual(didProgress(1));
action = await saga.take();
expect(action).toEqual(
alertsShowAlert(
-9
View File
@@ -75,7 +75,6 @@ import {
MetadataProblem,
didFailToFinish,
didFinish,
didProgress,
didStart,
firmwareDidFailToFlashEV3,
firmwareDidFailToFlashUsbDfu,
@@ -531,8 +530,6 @@ function* handleFlashFirmware(action: ReturnType<typeof flashFirmware>): Generat
);
yield* waitForDidRequest(programAction.id);
yield* put(didProgress(offset / firmware.length));
yield* put(
alertsShowAlert(
'firmware',
@@ -617,8 +614,6 @@ function* handleFlashFirmware(action: ReturnType<typeof flashFirmware>): Generat
yield* disconnectAndCancel();
}
yield* put(didProgress(1));
yield* put(
alertsShowAlert(
'firmware',
@@ -1286,10 +1281,6 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
}
}
yield* put(
didProgress((i + sectorData.byteLength) / action.firmware.byteLength),
);
yield* put(
alertsShowAlert(
'firmware',