summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorAAGaming <aagaming@riseup.net>2024-06-27 00:09:00 -0400
committerAAGaming <aagaming@riseup.net>2024-06-27 00:09:00 -0400
commitd067fe6361b6bebd2d1ae4adff2cf3e49cbd99fe (patch)
treeac65d9df2a083644c54896767a0bf5670bd8bd84 /frontend
parentc02a78ed6e1d9c21e84b60d9a5b077d0ee547a8f (diff)
downloaddecky-loader-d067fe6361b6bebd2d1ae4adff2cf3e49cbd99fe.tar.gz
decky-loader-d067fe6361b6bebd2d1ae4adff2cf3e49cbd99fe.zip
add some errorboundaries
Diffstat (limited to 'frontend')
-rw-r--r--frontend/src/components/PluginView.tsx6
-rw-r--r--frontend/src/router-hook.tsx10
-rw-r--r--frontend/src/tabs-hook.tsx4
3 files changed, 11 insertions, 9 deletions
diff --git a/frontend/src/components/PluginView.tsx b/frontend/src/components/PluginView.tsx
index 997e576b..07367bc3 100644
--- a/frontend/src/components/PluginView.tsx
+++ b/frontend/src/components/PluginView.tsx
@@ -1,4 +1,4 @@
-import { ButtonItem, Focusable, PanelSection, PanelSectionRow } from '@decky/ui';
+import { ButtonItem, ErrorBoundary, Focusable, PanelSection, PanelSectionRow } from '@decky/ui';
import { FC, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FaEyeSlash } from 'react-icons/fa';
@@ -29,7 +29,9 @@ const PluginView: FC = () => {
<Focusable onCancelButton={closeActivePlugin}>
<TitleView />
<div style={{ height: '100%', paddingTop: '16px' }}>
- {(visible || activePlugin.alwaysRender) && activePlugin.content}
+ <ErrorBoundary>
+ {(visible || activePlugin.alwaysRender) && activePlugin.content}
+ </ErrorBoundary>
</div>
</Focusable>
);
diff --git a/frontend/src/router-hook.tsx b/frontend/src/router-hook.tsx
index a42c2daa..7b66d351 100644
--- a/frontend/src/router-hook.tsx
+++ b/frontend/src/router-hook.tsx
@@ -1,4 +1,4 @@
-import { Export, Patch, afterPatch, findModuleExport } from '@decky/ui';
+import { ErrorBoundary, Focusable, Patch, afterPatch } from '@decky/ui';
import { FC, ReactElement, ReactNode, cloneElement, createElement, memo } from 'react';
import type { Route } from 'react-router';
@@ -41,9 +41,7 @@ class RouterHook extends Logger {
window.__ROUTER_HOOK_INSTANCE?.deinit?.();
window.__ROUTER_HOOK_INSTANCE = this;
- this.gamepadWrapper = findModuleExport((e: Export) =>
- e?.render?.toString()?.includes('["flow-children","onActivate","onCancel","focusClassName",'),
- );
+ this.gamepadWrapper = Focusable;
let Route: new () => Route;
// Used to store the new replicated routes we create to allow routes to be unpatched.
@@ -63,7 +61,9 @@ class RouterHook extends Logger {
routes.forEach(({ component, props }, path) => {
newRouterArray.push(
<Route path={path} {...props}>
- {createElement(component)}
+ <ErrorBoundary>
+ {createElement(component)}
+ </ErrorBoundary>
</Route>,
);
});
diff --git a/frontend/src/tabs-hook.tsx b/frontend/src/tabs-hook.tsx
index f42a4aea..4ddea44a 100644
--- a/frontend/src/tabs-hook.tsx
+++ b/frontend/src/tabs-hook.tsx
@@ -1,5 +1,5 @@
// TabsHook for versions after the Desktop merge
-import { Patch, QuickAccessTab, afterPatch, findInReactTree, getReactRoot, sleep } from '@decky/ui';
+import { ErrorBoundary, Patch, QuickAccessTab, afterPatch, findInReactTree, getReactRoot, sleep } from '@decky/ui';
import { QuickAccessVisibleStateProvider } from './components/QuickAccessVisibleState';
import Logger from './logger';
@@ -147,7 +147,7 @@ class TabsHook extends Logger {
decky: true,
initialVisibility: visible,
};
- tab.panel = <QuickAccessVisibleStateProvider tab={tab}>{content}</QuickAccessVisibleStateProvider>;
+ tab.panel = <ErrorBoundary><QuickAccessVisibleStateProvider tab={tab}>{content}</QuickAccessVisibleStateProvider></ErrorBoundary>;
existingTabs.push(tab);
}
}