fix(lib/plugins): forget initial persisted states when un/reinstalling a plugin
This commit is contained in:
parent
2b665164e9
commit
a5290d314f
2 changed files with 11 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ import { getErrorStack } from '@revenge-mod/utils/error'
|
|||
import { pUnscopedApi } from '../apis'
|
||||
import {
|
||||
disablePlugin,
|
||||
forgetInitialPluginState,
|
||||
getInternalPluginMeta,
|
||||
handlePluginError,
|
||||
InternalPluginFlags,
|
||||
|
|
@ -67,6 +68,9 @@ export function registerExternalPlugins() {
|
|||
const { plugin } = result
|
||||
|
||||
try {
|
||||
// Drop the stale boot snapshot entry (from before a mid-session uninstall)
|
||||
// so the fresh install registers disabled
|
||||
forgetInitialPluginState(plugin.manifest.id)
|
||||
registerExternalPlugin(plugin)
|
||||
} catch (e) {
|
||||
pEmitter.emit('install', { error: toPluginError(e) })
|
||||
|
|
@ -189,6 +193,9 @@ export async function uninstallExternalPlugin(plugin: AnyPlugin) {
|
|||
|
||||
await callNativeMethod('revenge.plugins.uninstall', [plugin.manifest.id])
|
||||
|
||||
// Native cleared its persisted flags, drop our boot snapshot entry too
|
||||
forgetInitialPluginState(plugin.manifest.id)
|
||||
|
||||
pList.delete(plugin.manifest.id)
|
||||
pEmitter.emit('unregister', plugin)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,6 +238,10 @@ const { states: InitialPersistedStates }: PersistedPluginStates =
|
|||
states: {},
|
||||
}
|
||||
|
||||
export function forgetInitialPluginState(id: PluginManifest['id']) {
|
||||
delete InitialPersistedStates[id]
|
||||
}
|
||||
|
||||
// Native is the source of truth, we're expecting dispatches from native to sync states
|
||||
registerJSMethod('revenge.plugins.states.update', (id, state) => {
|
||||
applyPluginFlags(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue