initial implementation of new router and qam hooks

This commit is contained in:
AAGaming
2024-07-09 02:35:24 -04:00
parent dcfaf11696
commit 28c7254ef6
4 changed files with 167 additions and 191 deletions
+9 -2
View File
@@ -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(
@@ -76,6 +74,11 @@ class ErrorBoundaryHook extends Logger {
}
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.
ValveErrorBoundary.prototype._deckyForceRerender = function (this: any) {
this.setState({...this.state, _deckyForceRerender: true});
}
}
public temporarilyDisableReporting() {