remove useless toast delay

This commit is contained in:
AAGaming
2024-08-08 15:20:47 -04:00
parent 1265672067
commit 7a161a5b83

View File

@@ -1,13 +1,5 @@
import type { ToastData, ToastNotification } from '@decky/api';
import {
ErrorBoundary,
Patch,
callOriginal,
findModuleExport,
injectFCTrampoline,
replacePatch,
sleep,
} from '@decky/ui';
import { ErrorBoundary, Patch, callOriginal, findModuleExport, injectFCTrampoline, replacePatch } from '@decky/ui';
import Toast from './components/Toast';
import Logger from './logger';
@@ -29,8 +21,6 @@ declare global {
class Toaster extends Logger {
private toastPatch?: Patch;
private markReady!: () => void;
private ready = new Promise<void>((r) => (this.markReady = r));
constructor() {
super('Toaster');
@@ -53,7 +43,6 @@ class Toaster extends Logger {
});
this.log('Initialized');
sleep(4000).then(this.markReady);
}
toast(toast: ToastData): ToastNotification {
@@ -120,7 +109,11 @@ class Toaster extends Logger {
}
}, toast.expiration);
}
this.ready.then(() => window.NotificationStore.ProcessNotification(info, toastData, ToastType.New));
try {
window.NotificationStore.ProcessNotification(info, toastData, ToastType.New);
} catch (e) {
this.error('Error while sending toast:', e);
}
return toastResult;
}