Skip to content

Commit

Permalink
Desktop: Fixed default migration logic
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Oct 28, 2021
1 parent 9704e75 commit e247be1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/lib/models/Setting.test.ts
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/models/Setting.ts
Expand Up @@ -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) {
Expand Down

0 comments on commit e247be1

Please sign in to comment.