Skip to content

Commit

Permalink
♻️ Consolidate to WebConfig._localOnlyKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
richardfrost committed Jul 16, 2024
1 parent 32be901 commit e0d7393
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/script/optionPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ export default class OptionPage {
async convertStorageLocation(evt: Event = null, silent = false) {
const configSyncLargeKeys = document.getElementById('configSyncLargeKeys') as HTMLInputElement;
this.cfg.syncLargeKeys = configSyncLargeKeys.checked;
const keys = this.Class.Config._localConfigKeys;
const keys = this.Class.Config._largeKeys.concat(['syncLargeKeys']);

try {
await this.cfg.save(keys);
Expand Down
5 changes: 2 additions & 3 deletions src/script/webConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ export default class WebConfig extends Config {

static _defaults = this.initializeDefaults({}, this._configDefaults, this._webDefaults) as WebConfig;
static _persistableKeys = Object.keys(this._defaults); // Make sure _defaults has already been assigned before this
static readonly _localConfigKeys = ['domains', 'syncLargeKeys', 'words'];
static readonly _localOnlyKeys = ['background', 'stats'];
static readonly _localOnlyKeys = ['background', 'stats', 'syncLargeKeys'];
static readonly _maxSplitKeys = 64;
static readonly _largeKeys = ['domains', 'words'];

Expand Down Expand Up @@ -402,7 +401,7 @@ export default class WebConfig extends Config {
async resetPreserveStats() {
try {
await this.Class.resetSyncStorage();
await this.Class.removeLocalStorage(this.Class._localConfigKeys);
await this.Class.removeLocalStorage(removeFromArray(this.Class._localOnlyKeys, 'stats'));
} catch (err) {
logger.error('Failed to clear storage.', err);
throw new Error(`Failed to clear storage. ${err.message}`);
Expand Down

0 comments on commit e0d7393

Please sign in to comment.