Skip to content

Commit

Permalink
Apply custom dict css when resetting settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuuuube committed Oct 5, 2024
1 parent 9d549ec commit af4f904
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions ext/js/pages/settings/dictionary-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,31 +677,26 @@ export class DictionaryController {
optionsFull = await settingsController.getOptionsFull();
}

/** @type {Set<string>} */
const installedDictionaries = new Set();
for (const {title} of dictionaries) {
installedDictionaries.add(title);
}

/** @type {import('settings-modifications').Modification[]} */
const targets = [];
const {profiles} = optionsFull;
for (let i = 0, ii = profiles.length; i < ii; ++i) {
let modified = false;
const missingDictionaries = new Set(installedDictionaries);
const missingDictionaries = [...dictionaries];
const dictionaryOptionsArray = profiles[i].options.dictionaries;
for (let j = dictionaryOptionsArray.length - 1; j >= 0; --j) {
const {name} = dictionaryOptionsArray[j];
if (installedDictionaries.has(name)) {
missingDictionaries.delete(name);
const missingDictionariesNameIndex = missingDictionaries.findIndex((x) => x.title === name);
if (missingDictionariesNameIndex !== -1) {
missingDictionaries.splice(missingDictionariesNameIndex, 1);
} else {
dictionaryOptionsArray.splice(j, 1);
modified = true;
}
}

for (const name of missingDictionaries) {
const value = DictionaryController.createDefaultDictionarySettings(name, newDictionariesEnabled, '');
for (const {title, styles} of missingDictionaries) {
const value = DictionaryController.createDefaultDictionarySettings(title, newDictionariesEnabled, styles);
dictionaryOptionsArray.push(value);
modified = true;
}
Expand Down

0 comments on commit af4f904

Please sign in to comment.