Skip to content

Commit 0d0e366

Browse files
committed
firmware/sagas: fix progress toasts not being removed on error
Add some calls to hide the progress toasts when an error occurs during firmware flashing. Without this, the toasts would remain visible even after the error alert was shown.
1 parent 830855e commit 0d0e366

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/firmware/sagas.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,7 @@ function* handleRestoreOfficialDfu(
10371037
}
10381038
}
10391039

1040+
const firmwareEv3ProgressToastId = 'firmware.ev3.progress';
10401041
const getNextEV3MessageId = createCountFunc();
10411042

10421043
function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator {
@@ -1256,6 +1257,7 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
12561257
error: eraseError,
12571258
}),
12581259
);
1260+
yield* put(alertsHideAlert(firmwareEv3ProgressToastId));
12591261
// FIXME: should have a better error reason
12601262
yield* put(didFailToFinish(FailToFinishReasonType.Unknown, eraseError));
12611263
yield* put(firmwareDidFailToFlashEV3());
@@ -1273,6 +1275,7 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
12731275
error: sendError,
12741276
}),
12751277
);
1278+
yield* put(alertsHideAlert(firmwareEv3ProgressToastId));
12761279
// FIXME: should have a better error reason
12771280
yield* put(didFailToFinish(FailToFinishReasonType.Unknown, sendError));
12781281
yield* put(firmwareDidFailToFlashEV3());
@@ -1289,7 +1292,7 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
12891292
action: 'flash',
12901293
progress: (i + sectorData.byteLength) / action.firmware.byteLength,
12911294
},
1292-
firmwareBleProgressToastId,
1295+
firmwareEv3ProgressToastId,
12931296
true,
12941297
),
12951298
);
@@ -1303,7 +1306,7 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
13031306
action: 'flash',
13041307
progress: 1,
13051308
},
1306-
firmwareBleProgressToastId,
1309+
firmwareEv3ProgressToastId,
13071310
true,
13081311
),
13091312
);

0 commit comments

Comments
 (0)