mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
3992 Fix: handle null duration in toast ns function
extend SnackbarEvents typing to allow null in third argument also remove typos in Electron.tsx init functions comments
This commit is contained in:
parent
9c579e294a
commit
5c0c130b4b
@ -139,7 +139,7 @@ function initAppNotifier(): void {
|
|||||||
toast: (message: string, type: ToastVariant, duration = 2000) => SnackbarEvents.emit(message, type, duration),
|
toast: (message: string, type: ToastVariant, duration = 2000) => SnackbarEvents.emit(message, type, duration),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Will be consumud by the electron wrapper.
|
// Will be consumed by the electron wrapper.
|
||||||
window.appNotifier = funcs;
|
window.appNotifier = funcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ function initSaveFunctions(): void {
|
|||||||
pushSaveData: (base64save: string, automatic = false): void => Router.toImportSave(base64save, automatic),
|
pushSaveData: (base64save: string, automatic = false): void => Router.toImportSave(base64save, automatic),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Will be consumud by the electron wrapper.
|
// Will be consumed by the electron wrapper.
|
||||||
window.appSaveFns = funcs;
|
window.appSaveFns = funcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1849,7 +1849,7 @@ const base: InternalAPI<NS> = {
|
|||||||
(_message: unknown, _variant: unknown = ToastVariant.SUCCESS, _duration: unknown = 2000): void => {
|
(_message: unknown, _variant: unknown = ToastVariant.SUCCESS, _duration: unknown = 2000): void => {
|
||||||
const message = helpers.string(ctx, "message", _message);
|
const message = helpers.string(ctx, "message", _message);
|
||||||
const variant = helpers.string(ctx, "variant", _variant);
|
const variant = helpers.string(ctx, "variant", _variant);
|
||||||
const duration = helpers.number(ctx, "duration", _duration);
|
const duration = _duration === null ? null : helpers.number(ctx, "duration", _duration);
|
||||||
if (!checkEnum(ToastVariant, variant))
|
if (!checkEnum(ToastVariant, variant))
|
||||||
throw new Error(`variant must be one of ${Object.values(ToastVariant).join(", ")}`);
|
throw new Error(`variant must be one of ${Object.values(ToastVariant).join(", ")}`);
|
||||||
SnackbarEvents.emit(message, variant, duration);
|
SnackbarEvents.emit(message, variant, duration);
|
||||||
|
@ -43,7 +43,7 @@ export function SnackbarProvider(props: IProps): React.ReactElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SnackbarEvents = new EventEmitter<[string | React.ReactNode, ToastVariant, number]>();
|
export const SnackbarEvents = new EventEmitter<[string | React.ReactNode, ToastVariant, number | null]>();
|
||||||
|
|
||||||
export function Snackbar(): React.ReactElement {
|
export function Snackbar(): React.ReactElement {
|
||||||
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
|
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
|
||||||
|
Loading…
Reference in New Issue
Block a user