diff options
| author | AAGaming <aagaming@riseup.net> | 2024-08-05 14:07:10 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-05 14:07:10 -0400 |
| commit | 131f0961ff451ec47376483178e092c8d7403b27 (patch) | |
| tree | 4d2ea34e8220e14c4b820cc1ad38face7193f6fe /frontend/src/errorboundary-hook.tsx | |
| parent | 75aa1e4851445646994ba3a61ff41325403359fb (diff) | |
| download | decky-loader-131f0961ff451ec47376483178e092c8d7403b27.tar.gz decky-loader-131f0961ff451ec47376483178e092c8d7403b27.zip | |
Rewrite router/tabs/toaster hooks (#661)
Diffstat (limited to 'frontend/src/errorboundary-hook.tsx')
| -rw-r--r-- | frontend/src/errorboundary-hook.tsx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/frontend/src/errorboundary-hook.tsx b/frontend/src/errorboundary-hook.tsx index 8c96d9f4..95be77ab 100644 --- a/frontend/src/errorboundary-hook.tsx +++ b/frontend/src/errorboundary-hook.tsx @@ -22,9 +22,7 @@ class ErrorBoundaryHook extends Logger { this.log('Initialized'); window.__ERRORBOUNDARY_HOOK_INSTANCE?.deinit?.(); window.__ERRORBOUNDARY_HOOK_INSTANCE = this; - } - init() { // valve writes only the sanest of code const exp = /^\(\)=>\(.\|\|.\(new .\),.\)$/; const initErrorReportingStore = findModuleExport( @@ -71,11 +69,16 @@ class ErrorBoundaryHook extends Logger { }); if (!ErrorBoundary) { - this.error('could not find ValveErrorBoundary'); + this.error('@decky/ui could not find ErrorBoundary, skipping patch'); return; } this.errorBoundaryPatch = replacePatch(ErrorBoundary.prototype, 'render', function (this: any) { + if (this.state._deckyForceRerender) { + const stateClone = { ...this.state, _deckyForceRerender: null }; + this.setState(stateClone); + return null; + } if (this.state.error) { const store = Object.getPrototypeOf(this)?.constructor?.sm_ErrorReportingStore || errorReportingStore; return ( @@ -89,6 +92,10 @@ class ErrorBoundaryHook extends Logger { } return callOriginal; }); + // Small hack that gives us a lot more flexibility to force rerenders. + ErrorBoundary.prototype._deckyForceRerender = function (this: any) { + this.setState({ ...this.state, _deckyForceRerender: true }); + }; } public temporarilyDisableReporting() { |
