firmware/sagas: fix progress alerts

These were being replaced (dismissed then new alert) instead of updated.
This commit is contained in:
David Lechner
2022-10-21 16:26:43 -05:00
parent 4400c0663e
commit fa00c0aea6
4 changed files with 28 additions and 3 deletions
+4 -2
View File
@@ -11,14 +11,15 @@ import { AlertActions, AlertDomain, AlertProps, AlertSpecific } from '../alerts'
* @param specific The specific alert for the domain.
* @param props Any additional properties required by this specific alert.
* @param key Optional key to use as unique identifier for toast instead `<domain>.<specific>.<props>`.
* @param update Optional boolean flag to update existing alert instead of replacing it.
*/
export const alertsShowAlert = createAction(
<D extends AlertDomain, S extends AlertSpecific<D>>(
domain: D,
specific: S,
...args: AlertProps<D, S> extends never
? [props?: never]
: [props: AlertProps<D, S>, key?: string]
? [args?: never]
: [props: AlertProps<D, S>, key?: string, update?: boolean]
) => ({
type: 'alerts.action.showAlert',
domain,
@@ -26,6 +27,7 @@ export const alertsShowAlert = createAction(
// HACK: using varargs to allow props and key to be optional
props: args.at(0),
key: args.at(1),
update: args.at(2),
}),
);
+1 -1
View File
@@ -23,7 +23,7 @@ function* handleShowAlert(action: ReturnType<typeof alertsShowAlert>): Generator
// if a toast with the same parameters is already open, close it so we
// can open it again without duplicates.
if (existing.length > 0) {
if (!action.update && existing.length > 0) {
toaster.dismiss(key);
yield* delay(500);
}