Skip to content

Commit 245a35f

Browse files
committed
fix config save will have duplicated config
1 parent 792d860 commit 245a35f

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

packages/hydrooj/src/loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class Loader extends Service {
9999
if (!schema) return Object.freeze({});
100100
const schemaRequest = configScope ? Schema.object({
101101
[configScope]: schema,
102-
}) : schema;
102+
}).description(configScope) : schema;
103103
await this.ctx.setting._tryMigrateConfig(schemaRequest);
104104
const res = this.ctx.setting.requestConfig(schemaRequest, dynamic);
105105
return configScope ? res[configScope] : res;

packages/hydrooj/src/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ export class SettingService extends Service {
152152
requestConfig<T, S>(s: Schema<T, S>, dynamic = true): S {
153153
this.ctx.effect(() => {
154154
logger.debug('Loading config', s);
155+
const exist = this.settings.findIndex((v) => v.meta?.description === s.meta?.description);
156+
if (exist !== -1) this.settings.splice(exist, 1);
155157
this.settings.push(s);
156158
this._applySchema();
157159
return () => {

0 commit comments

Comments
 (0)