Skip to content

Commit a4aade5

Browse files
committed
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.
1 parent 7fe080b commit a4aade5

File tree

3 files changed

+0
-86
lines changed

3 files changed

+0
-86
lines changed

src/firmware/actions.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,6 @@ export const flashFirmware = createAction(
132132
}),
133133
);
134134

135-
/**
136-
* Action that indicates flashing firmware started.
137-
* @param total The total number of bytes to be flashed.
138-
*/
139-
export const didStart = createAction(() => ({
140-
type: 'flashFirmware.action.didStart',
141-
}));
142-
143-
/** Action that indicates that flashing firmware completed successfully. */
144-
export const didFinish = createAction(() => ({
145-
type: 'flashFirmware.action.didFinish',
146-
}));
147-
148135
// FIXME: get rid of this monstrosity
149136

150137
const didFailToFinishType = 'flashFirmware.action.didFailToFinish';

src/firmware/sagas.test.ts

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ import {
4242
HubError,
4343
MetadataProblem,
4444
didFailToFinish,
45-
didFinish,
46-
didStart,
4745
flashFirmware as flashFirmwareAction,
4846
} from './actions';
4947
import flashFirmware from './sagas';
@@ -124,12 +122,6 @@ describe('flashFirmware', () => {
124122
const mpyBinaryData = new Uint8Array(mpySize);
125123
saga.put(didCompile(mpyBinaryData));
126124

127-
// then start flashing the firmware
128-
129-
// should get didStart action just before starting to erase
130-
action = await saga.take();
131-
expect(action).toEqual(didStart());
132-
133125
// erase first
134126

135127
action = await saga.take();
@@ -232,9 +224,6 @@ describe('flashFirmware', () => {
232224

233225
// then we are done
234226

235-
action = await saga.take();
236-
expect(action).toEqual(didFinish());
237-
238227
await saga.end();
239228
});
240229

@@ -284,12 +273,6 @@ describe('flashFirmware', () => {
284273
saga.put(didRequest(0));
285274
saga.put(infoResponse(0x01000000, 0x08005000, 0x081f800, HubType.MoveHub));
286275

287-
// then start flashing the firmware
288-
289-
// should get didStart action just before starting to erase
290-
action = await saga.take();
291-
expect(action).toEqual(didStart());
292-
293276
// erase first
294277

295278
action = await saga.take();
@@ -392,9 +375,6 @@ describe('flashFirmware', () => {
392375

393376
// then we are done
394377

395-
action = await saga.take();
396-
expect(action).toEqual(didFinish());
397-
398378
await saga.end();
399379
});
400380

@@ -1008,12 +988,6 @@ describe('flashFirmware', () => {
1008988
const mpyBinaryData = new Uint8Array(mpySize);
1009989
saga.put(didCompile(mpyBinaryData));
1010990

1011-
// then start flashing the firmware
1012-
1013-
// should get didStart action just before starting to erase
1014-
action = await saga.take();
1015-
expect(action).toEqual(didStart());
1016-
1017991
// erase first
1018992

1019993
action = await saga.take();
@@ -1121,12 +1095,6 @@ describe('flashFirmware', () => {
11211095
const mpyBinaryData = new Uint8Array(mpySize);
11221096
saga.put(didCompile(mpyBinaryData));
11231097

1124-
// then start flashing the firmware
1125-
1126-
// should get didStart action just before starting to erase
1127-
action = await saga.take();
1128-
expect(action).toEqual(didStart());
1129-
11301098
// erase first
11311099

11321100
action = await saga.take();
@@ -1243,12 +1211,6 @@ describe('flashFirmware', () => {
12431211
const mpyBinaryData = new Uint8Array(mpySize);
12441212
saga.put(didCompile(mpyBinaryData));
12451213

1246-
// then start flashing the firmware
1247-
1248-
// should get didStart action just before starting to erase
1249-
action = await saga.take();
1250-
expect(action).toEqual(didStart());
1251-
12521214
// erase first
12531215

12541216
action = await saga.take();
@@ -1416,12 +1378,6 @@ describe('flashFirmware', () => {
14161378
const mpyBinaryData = new Uint8Array(mpySize);
14171379
saga.put(didCompile(mpyBinaryData));
14181380

1419-
// then start flashing the firmware
1420-
1421-
// should get didStart action just before starting to erase
1422-
action = await saga.take();
1423-
expect(action).toEqual(didStart());
1424-
14251381
// erase first
14261382

14271383
action = await saga.take();
@@ -1594,12 +1550,6 @@ describe('flashFirmware', () => {
15941550
saga.put(didRequest(0));
15951551
saga.put(infoResponse(0x01000000, 0x08005000, 0x081f800, HubType.MoveHub));
15961552

1597-
// then start flashing the firmware
1598-
1599-
// should get didStart action just before starting to erase
1600-
action = await saga.take();
1601-
expect(action).toEqual(didStart());
1602-
16031553
// erase first
16041554

16051555
action = await saga.take();
@@ -1703,9 +1653,6 @@ describe('flashFirmware', () => {
17031653

17041654
// then we are done
17051655

1706-
action = await saga.take();
1707-
expect(action).toEqual(didFinish());
1708-
17091656
await saga.end();
17101657
});
17111658

@@ -2156,12 +2103,6 @@ describe('flashFirmware', () => {
21562103
const mpyBinaryData = new Uint8Array(mpySize);
21572104
saga.put(didCompile(mpyBinaryData));
21582105

2159-
// then start flashing the firmware
2160-
2161-
// should get didStart action just before starting to erase
2162-
action = await saga.take();
2163-
expect(action).toEqual(didStart());
2164-
21652106
// erase first
21662107

21672108
action = await saga.take();
@@ -2262,9 +2203,6 @@ describe('flashFirmware', () => {
22622203

22632204
// then we are done
22642205

2265-
action = await saga.take();
2266-
expect(action).toEqual(didFinish());
2267-
22682206
await saga.end();
22692207
});
22702208
});

src/firmware/sagas.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ import {
7474
HubError,
7575
MetadataProblem,
7676
didFailToFinish,
77-
didFinish,
78-
didStart,
7977
firmwareDidFailToFlashEV3,
8078
firmwareDidFailToFlashUsbDfu,
8179
firmwareDidFailToRestoreOfficialDfu,
@@ -465,8 +463,6 @@ function* handleFlashFirmware(action: ReturnType<typeof flashFirmware>): Generat
465463
}
466464
}
467465

468-
yield* put(didStart());
469-
470466
yield* put(
471467
alertsShowAlert(
472468
'firmware',
@@ -630,8 +626,6 @@ function* handleFlashFirmware(action: ReturnType<typeof flashFirmware>): Generat
630626
// this will cause the remote device to disconnect and reboot
631627
const rebootAction = yield* put(rebootRequest(nextMessageId()));
632628
yield* waitForDidRequest(rebootAction.id);
633-
634-
yield* put(didFinish());
635629
} catch (err) {
636630
yield* put(didFailToFinish(FailToFinishReasonType.Unknown, ensureError(err)));
637631
yield* disconnectAndCancel();
@@ -1211,9 +1205,6 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
12111205
return [new DataView(reply.payload), undefined];
12121206
}
12131207

1214-
// FIXME: should be called much earlier.
1215-
yield* put(didStart());
1216-
12171208
const sectorSize = 64 * 1024; // flash memory sector size
12181209
const maxPayloadSize = 1018; // maximum payload size for EV3 commands
12191210

@@ -1288,8 +1279,6 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
12881279
return;
12891280
}
12901281

1291-
yield* put(didFinish());
1292-
12931282
yield* cleanup();
12941283

12951284
yield* put(firmwareDidFlashEV3());

0 commit comments

Comments
 (0)