summaryrefslogtreecommitdiff
path: root/frontend/src/toaster.tsx
diff options
context:
space:
mode:
authorAAGaming <aagaming@riseup.net>2024-08-07 16:14:18 -0400
committerAAGaming <aagaming@riseup.net>2024-08-07 16:14:18 -0400
commit65b6883dcc42944607eb0efa1f28e41f57335313 (patch)
tree38db3185d6720552daa978149279928d271df19a /frontend/src/toaster.tsx
parent166c7ea8a7ea74d9a61d84ebe16556cec9e7cc83 (diff)
downloaddecky-loader-65b6883dcc42944607eb0efa1f28e41f57335313.tar.gz
decky-loader-65b6883dcc42944607eb0efa1f28e41f57335313.zip
handle crashloops and disable decky for the user
Diffstat (limited to 'frontend/src/toaster.tsx')
-rw-r--r--frontend/src/toaster.tsx19
1 files changed, 16 insertions, 3 deletions
diff --git a/frontend/src/toaster.tsx b/frontend/src/toaster.tsx
index e45b14a4..4f67c589 100644
--- a/frontend/src/toaster.tsx
+++ b/frontend/src/toaster.tsx
@@ -1,5 +1,13 @@
import type { ToastData, ToastNotification } from '@decky/api';
-import { Patch, callOriginal, findModuleExport, injectFCTrampoline, replacePatch } from '@decky/ui';
+import {
+ ErrorBoundary,
+ Patch,
+ callOriginal,
+ findModuleExport,
+ injectFCTrampoline,
+ replacePatch,
+ sleep,
+} from '@decky/ui';
import Toast from './components/Toast';
import Logger from './logger';
@@ -21,6 +29,8 @@ declare global {
class Toaster extends Logger {
private toastPatch?: Patch;
+ private markReady!: () => void;
+ private ready = new Promise<void>((r) => (this.markReady = r));
constructor() {
super('Toaster');
@@ -34,13 +44,16 @@ class Toaster extends Logger {
this.toastPatch = replacePatch(patchedRenderer, 'component', (args: any[]) => {
if (args?.[0]?.group?.decky || args?.[0]?.group?.notifications?.[0]?.decky) {
return args[0].group.notifications.map((notification: any) => (
- <Toast toast={notification.data} newIndicator={notification.bNewIndicator} location={args?.[0]?.location} />
+ <ErrorBoundary>
+ <Toast toast={notification.data} newIndicator={notification.bNewIndicator} location={args?.[0]?.location} />
+ </ErrorBoundary>
));
}
return callOriginal;
});
this.log('Initialized');
+ sleep(4000).then(this.markReady);
}
toast(toast: ToastData): ToastNotification {
@@ -107,7 +120,7 @@ class Toaster extends Logger {
}
}, toast.expiration);
}
- window.NotificationStore.ProcessNotification(info, toastData, ToastType.New);
+ this.ready.then(() => window.NotificationStore.ProcessNotification(info, toastData, ToastType.New));
return toastResult;
}