Skip to content

Commit

Permalink
add some errorboundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
AAGaming00 committed Jun 27, 2024
1 parent c02a78e commit d067fe6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions frontend/src/components/PluginView.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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>
);
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/router-hook.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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.
Expand All @@ -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>,
);
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/tabs-hook.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit d067fe6

Please sign in to comment.