mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
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.
This commit is contained in:
@@ -1037,6 +1037,7 @@ function* handleRestoreOfficialDfu(
|
||||
}
|
||||
}
|
||||
|
||||
const firmwareEv3ProgressToastId = 'firmware.ev3.progress';
|
||||
const getNextEV3MessageId = createCountFunc();
|
||||
|
||||
function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator {
|
||||
@@ -1256,6 +1257,7 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
|
||||
error: eraseError,
|
||||
}),
|
||||
);
|
||||
yield* put(alertsHideAlert(firmwareEv3ProgressToastId));
|
||||
// FIXME: should have a better error reason
|
||||
yield* put(didFailToFinish(FailToFinishReasonType.Unknown, eraseError));
|
||||
yield* put(firmwareDidFailToFlashEV3());
|
||||
@@ -1273,6 +1275,7 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
|
||||
error: sendError,
|
||||
}),
|
||||
);
|
||||
yield* put(alertsHideAlert(firmwareEv3ProgressToastId));
|
||||
// FIXME: should have a better error reason
|
||||
yield* put(didFailToFinish(FailToFinishReasonType.Unknown, sendError));
|
||||
yield* put(firmwareDidFailToFlashEV3());
|
||||
@@ -1289,7 +1292,7 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
|
||||
action: 'flash',
|
||||
progress: (i + sectorData.byteLength) / action.firmware.byteLength,
|
||||
},
|
||||
firmwareBleProgressToastId,
|
||||
firmwareEv3ProgressToastId,
|
||||
true,
|
||||
),
|
||||
);
|
||||
@@ -1303,7 +1306,7 @@ function* handleFlashEV3(action: ReturnType<typeof firmwareFlashEV3>): Generator
|
||||
action: 'flash',
|
||||
progress: 1,
|
||||
},
|
||||
firmwareBleProgressToastId,
|
||||
firmwareEv3ProgressToastId,
|
||||
true,
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user