From 3298c8d88a809db91c9c0cdb88b7d77d384ed7f0 Mon Sep 17 00:00:00 2001 From: Hieuzest Date: Thu, 22 Aug 2024 23:19:11 +0800 Subject: [PATCH] fix(commands): prevent overwriting oldconfig of commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CommandManager.config 和 CommandManager.ctx.scope.config 在初始化时为同一值,这将导致 CommandManager.update() 先重写配置项后触发 ctx.scope.update(), 此时 ctx.scope.config 已经被修改,导致 internal/before-update 中无法区分是否改动。 而 ctx.scope.update() 中调用了 schema(), 因此后续并不会出现问题。因而此pr在初始化时强制让二者独立来避免此问题。 --- plugins/commands/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/commands/src/index.ts b/plugins/commands/src/index.ts index af65f816..31cc6424 100644 --- a/plugins/commands/src/index.ts +++ b/plugins/commands/src/index.ts @@ -82,6 +82,7 @@ export class CommandManager { public snapshots: Dict = Object.create(null) constructor(private ctx: Context, private config: Dict) { + this.config = CommandManager.schema(config) this.refresh = this.ctx.debounce(() => { this._cache = null this.entry?.refresh()