Skip to content

Commit 830855e

Browse files
committed
firmware: remove progress/didProgress
Remove the didProgress action and progress state, as they were not being used.
1 parent 4469e17 commit 830855e

File tree

5 files changed

+4
-74
lines changed

5 files changed

+4
-74
lines changed

src/firmware/actions.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2020-2025 The Pybricks Authors
2+
// Copyright (c) 2020-2026 The Pybricks Authors
33

44
import { FirmwareReaderError, HubType } from '@pybricks/firmware';
55
import { createAction } from '../actions';
@@ -139,15 +139,6 @@ export const didStart = createAction(() => ({
139139
type: 'flashFirmware.action.didStart',
140140
}));
141141

142-
/**
143-
* Action that indicates current firmware flashing progress.
144-
* @param value The current progress (0 to 1).
145-
*/
146-
export const didProgress = createAction((value: number) => {
147-
// assert(value >= 0 && value <= 1, 'value out of range');
148-
return { type: 'flashFirmware.action.didProgress', value };
149-
});
150-
151142
/** Action that indicates that flashing firmware completed successfully. */
152143
export const didFinish = createAction(() => ({
153144
type: 'flashFirmware.action.didFinish',

src/firmware/reducers.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2021-2025 The Pybricks Authors
2+
// Copyright (c) 2021-2026 The Pybricks Authors
33

44
import { AnyAction } from 'redux';
55
import {
66
FailToFinishReasonType,
77
didFailToFinish,
88
didFinish,
9-
didProgress,
109
didStart,
1110
} from './actions';
1211
import reducers from './reducers';
@@ -26,7 +25,6 @@ test('initial state', () => {
2625
"isFirmwareFlashEV3InProgress": false,
2726
"isFirmwareFlashUsbDfuInProgress": false,
2827
"isFirmwareRestoreOfficialDfuInProgress": false,
29-
"progress": null,
3028
"restoreOfficialDialog": {
3129
"isOpen": false,
3230
},
@@ -44,8 +42,3 @@ test('flashing', () => {
4442
).flashing,
4543
).toBe(false);
4644
});
47-
48-
test('progress', () => {
49-
expect(reducers({ progress: 1 } as State, didStart()).progress).toBe(null);
50-
expect(reducers({ progress: null } as State, didProgress(1)).progress).toBe(1);
51-
});

src/firmware/reducers.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2021-2025 The Pybricks Authors
2+
// Copyright (c) 2021-2026 The Pybricks Authors
33

44
import { Reducer, combineReducers } from 'redux';
55
import {
66
didFailToFinish,
77
didFinish,
8-
didProgress,
98
didStart,
109
firmwareDidFailToFlashUsbDfu,
1110
firmwareDidFailToRestoreOfficialDfu,
@@ -33,18 +32,6 @@ const flashing: Reducer<boolean> = (state = false, action) => {
3332
return state;
3433
};
3534

36-
const progress: Reducer<number | null> = (state = null, action) => {
37-
if (didStart.matches(action)) {
38-
return null;
39-
}
40-
41-
if (didProgress.matches(action)) {
42-
return action.value;
43-
}
44-
45-
return state;
46-
};
47-
4835
const isFirmwareFlashUsbDfuInProgress: Reducer<boolean> = (state = false, action) => {
4936
if (firmwareFlashUsbDfu.matches(action)) {
5037
return true;
@@ -100,7 +87,6 @@ export default combineReducers({
10087
installPybricksDialog,
10188
restoreOfficialDialog,
10289
flashing,
103-
progress,
10490
isFirmwareFlashUsbDfuInProgress,
10591
isFirmwareRestoreOfficialDfuInProgress,
10692
isFirmwareFlashEV3InProgress,

src/firmware/sagas.test.ts

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2021-2024 The Pybricks Authors
2+
// Copyright (c) 2021-2026 The Pybricks Authors
33

44
import {
55
FirmwareMetadata,
@@ -43,7 +43,6 @@ import {
4343
MetadataProblem,
4444
didFailToFinish,
4545
didFinish,
46-
didProgress,
4746
didStart,
4847
flashFirmware as flashFirmwareAction,
4948
} from './actions';
@@ -175,9 +174,6 @@ describe('flashFirmware', () => {
175174

176175
saga.put(didRequest(id));
177176

178-
action = await saga.take();
179-
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
180-
181177
action = await saga.take();
182178
expect(action).toEqual(
183179
alertsShowAlert(
@@ -213,9 +209,6 @@ describe('flashFirmware', () => {
213209

214210
saga.put(programResponse(0x33, totalFirmwareSize));
215211

216-
action = await saga.take();
217-
expect(action).toEqual(didProgress(1));
218-
219212
action = await saga.take();
220213
expect(action).toEqual(
221214
alertsShowAlert(
@@ -341,9 +334,6 @@ describe('flashFirmware', () => {
341334

342335
saga.put(didRequest(id));
343336

344-
action = await saga.take();
345-
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
346-
347337
action = await saga.take();
348338
expect(action).toEqual(
349339
alertsShowAlert(
@@ -379,9 +369,6 @@ describe('flashFirmware', () => {
379369

380370
saga.put(programResponse(0xe0, totalFirmwareSize));
381371

382-
action = await saga.take();
383-
expect(action).toEqual(didProgress(1));
384-
385372
action = await saga.take();
386373
expect(action).toEqual(
387374
alertsShowAlert(
@@ -1306,9 +1293,6 @@ describe('flashFirmware', () => {
13061293

13071294
saga.put(didRequest(id));
13081295

1309-
action = await saga.take();
1310-
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
1311-
13121296
action = await saga.take();
13131297
expect(action).toEqual(
13141298
alertsShowAlert(
@@ -1482,9 +1466,6 @@ describe('flashFirmware', () => {
14821466

14831467
saga.put(didRequest(id));
14841468

1485-
action = await saga.take();
1486-
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
1487-
14881469
action = await saga.take();
14891470
expect(action).toEqual(
14901471
alertsShowAlert(
@@ -1664,9 +1645,6 @@ describe('flashFirmware', () => {
16641645

16651646
saga.put(didRequest(id));
16661647

1667-
action = await saga.take();
1668-
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
1669-
16701648
action = await saga.take();
16711649
expect(action).toEqual(
16721650
alertsShowAlert(
@@ -1702,9 +1680,6 @@ describe('flashFirmware', () => {
17021680

17031681
saga.put(programResponse(0xf3, totalFirmwareSize));
17041682

1705-
action = await saga.take();
1706-
expect(action).toEqual(didProgress(1));
1707-
17081683
action = await saga.take();
17091684
expect(action).toEqual(
17101685
alertsShowAlert(
@@ -2230,9 +2205,6 @@ describe('flashFirmware', () => {
22302205

22312206
saga.put(didRequest(id));
22322207

2233-
action = await saga.take();
2234-
expect(action).toEqual(didProgress(offset / totalFirmwareSize));
2235-
22362208
action = await saga.take();
22372209
expect(action).toEqual(
22382210
alertsShowAlert(
@@ -2267,9 +2239,6 @@ describe('flashFirmware', () => {
22672239

22682240
saga.put(programResponse(0x27, totalFirmwareSize));
22692241

2270-
action = await saga.take();
2271-
expect(action).toEqual(didProgress(1));
2272-
22732242
action = await saga.take();
22742243
expect(action).toEqual(
22752244
alertsShowAlert(

src/firmware/sagas.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ import {
7575
MetadataProblem,
7676
didFailToFinish,
7777
didFinish,
78-
didProgress,
7978
didStart,
8079
firmwareDidFailToFlashEV3,
8180
firmwareDidFailToFlashUsbDfu,
@@ -531,8 +530,6 @@ function* handleFlashFirmware(action: ReturnType<typeof flashFirmware>): Generat
531530
);
532531
yield* waitForDidRequest(programAction.id);
533532

534-
yield* put(didProgress(offset / firmware.length));
535-
536533
yield* put(
537534
alertsShowAlert(
538535
'firmware',
@@ -617,8 +614,6 @@ function* handleFlashFirmware(action: ReturnType<typeof flashFirmware>): Generat
617614
yield* disconnectAndCancel();
618615
}
619616

620-
yield* put(didProgress(1));
621-
622617
yield* put(
623618
alertsShowAlert(
624619
'firmware',
@@ -1286,10 +1281,6 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
12861281
}
12871282
}
12881283

1289-
yield* put(
1290-
didProgress((i + sectorData.byteLength) / action.firmware.byteLength),
1291-
);
1292-
12931284
yield* put(
12941285
alertsShowAlert(
12951286
'firmware',

0 commit comments

Comments
 (0)