add some errorboundaries

This commit is contained in:
AAGaming
2024-06-27 00:09:00 -04:00
parent c02a78ed6e
commit d067fe6361
3 changed files with 11 additions and 9 deletions
+4 -2
View File
@@ -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 { FC, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { FaEyeSlash } from 'react-icons/fa'; import { FaEyeSlash } from 'react-icons/fa';
@@ -29,7 +29,9 @@ const PluginView: FC = () => {
<Focusable onCancelButton={closeActivePlugin}> <Focusable onCancelButton={closeActivePlugin}>
<TitleView /> <TitleView />
<div style={{ height: '100%', paddingTop: '16px' }}> <div style={{ height: '100%', paddingTop: '16px' }}>
{(visible || activePlugin.alwaysRender) && activePlugin.content} <ErrorBoundary>
{(visible || activePlugin.alwaysRender) && activePlugin.content}
</ErrorBoundary>
</div> </div>
</Focusable> </Focusable>
); );
+5 -5
View File
@@ -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 { FC, ReactElement, ReactNode, cloneElement, createElement, memo } from 'react';
import type { Route } from 'react-router'; import type { Route } from 'react-router';
@@ -41,9 +41,7 @@ class RouterHook extends Logger {
window.__ROUTER_HOOK_INSTANCE?.deinit?.(); window.__ROUTER_HOOK_INSTANCE?.deinit?.();
window.__ROUTER_HOOK_INSTANCE = this; window.__ROUTER_HOOK_INSTANCE = this;
this.gamepadWrapper = findModuleExport((e: Export) => this.gamepadWrapper = Focusable;
e?.render?.toString()?.includes('["flow-children","onActivate","onCancel","focusClassName",'),
);
let Route: new () => Route; let Route: new () => Route;
// Used to store the new replicated routes we create to allow routes to be unpatched. // 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) => { routes.forEach(({ component, props }, path) => {
newRouterArray.push( newRouterArray.push(
<Route path={path} {...props}> <Route path={path} {...props}>
{createElement(component)} <ErrorBoundary>
{createElement(component)}
</ErrorBoundary>
</Route>, </Route>,
); );
}); });
+2 -2
View File
@@ -1,5 +1,5 @@
// TabsHook for versions after the Desktop merge // 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 { QuickAccessVisibleStateProvider } from './components/QuickAccessVisibleState';
import Logger from './logger'; import Logger from './logger';
@@ -147,7 +147,7 @@ class TabsHook extends Logger {
decky: true, decky: true,
initialVisibility: visible, initialVisibility: visible,
}; };
tab.panel = <QuickAccessVisibleStateProvider tab={tab}>{content}</QuickAccessVisibleStateProvider>; tab.panel = <ErrorBoundary><QuickAccessVisibleStateProvider tab={tab}>{content}</QuickAccessVisibleStateProvider></ErrorBoundary>;
existingTabs.push(tab); existingTabs.push(tab);
} }
} }