chore: cleanup

This commit is contained in:
PalmDevs 2025-07-18 02:02:34 +07:00
parent 9c8d55af21
commit 38b035966b
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA
2 changed files with 29 additions and 25 deletions

View file

@ -43,14 +43,15 @@ registerPlugin<{ storage: Storage }>(
if (api_.plugin.flags & PluginFlags.EnabledLate)
refreshSettingsOverviewScreen()
api_.cleanup(refreshSettingsOverviewScreen)
Promise.all([import('./react-devtools'), api.storage.get()]).then(
([rdt, settings]) => {
if (settings.devtools.autoConnect) rdt.connect()
},
)
},
stop() {
refreshSettingsOverviewScreen()
},
},
PluginFlags.Enabled,
InternalPluginFlags.Internal,

View file

@ -16,31 +16,34 @@ registerPlugin(
},
{
start({ cleanup }) {
const unsubEB = waitForModules(byName('ErrorBoundary'), exports => {
unsubEB()
const unsubEB = waitForModules(
byName<typeof DiscordErrorBoundary>('ErrorBoundary'),
exports => {
unsubEB()
instead(
(exports as typeof DiscordErrorBoundary).prototype,
'render',
function (this: DiscordErrorBoundary) {
if (this.state.error)
return (
<ErrorBoundaryScreen
error={this.state.error}
reload={this.handleReload.bind(this)}
rerender={() => {
this.setState({
error: null,
info: null,
})
}}
/>
)
instead(
exports.prototype,
'render',
function (this: DiscordErrorBoundary) {
if (this.state.error)
return (
<ErrorBoundaryScreen
error={this.state.error}
reload={this.handleReload.bind(this)}
rerender={() => {
this.setState({
error: null,
info: null,
})
}}
/>
)
return this.props.children
},
)
})
return this.props.children
},
)
},
)
cleanup(unsubEB)
},