From e247be1fa77e01d8ff9b1061159aa462e22624d8 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Thu, 28 Oct 2021 22:25:27 +0100 Subject: [PATCH] Desktop: Fixed default migration logic --- packages/lib/models/Setting.test.ts | 8 ++++++++ packages/lib/models/Setting.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/lib/models/Setting.test.ts b/packages/lib/models/Setting.test.ts index b6ded4eda..3566f36ff 100644 --- a/packages/lib/models/Setting.test.ts +++ b/packages/lib/models/Setting.test.ts @@ -226,6 +226,14 @@ describe('models/Setting', function() { expect(Setting.value('style.editor.contentMaxWidth')).toBe(600); // Changed })); + it('should skip values that are already set', (async () => { + await Setting.reset(); + + Setting.setValue('sync.target', 9); + Setting.applyDefaultMigrations(); + expect(Setting.value('sync.target')).toBe(9); // Not changed + })); + it('should allow skipping default migrations', (async () => { await Setting.reset(); diff --git a/packages/lib/models/Setting.ts b/packages/lib/models/Setting.ts index a079d42df..23910e9be 100644 --- a/packages/lib/models/Setting.ts +++ b/packages/lib/models/Setting.ts @@ -1457,7 +1457,7 @@ class Setting extends BaseModel { } public static isSet(key: string) { - return key in this.cache_; + return this.cache_.find(d => d.key === key); } static keyDescription(key: string, appType: AppType = null) {