Fix dictionary settings not being deleted when deleting a single dictionary (#893)
This commit is contained in:
parent
2f96218e33
commit
1a91935dd7
@ -351,6 +351,7 @@ class DictionaryController {
|
||||
};
|
||||
|
||||
await this._deleteDictionaryInternal(dictionaryTitle, onProgress);
|
||||
await this._deleteDictionarySettings(dictionaryTitle);
|
||||
} catch (e) {
|
||||
yomichan.logError(e);
|
||||
} finally {
|
||||
@ -389,4 +390,18 @@ class DictionaryController {
|
||||
await dictionaryDatabase.prepare();
|
||||
return dictionaryDatabase;
|
||||
}
|
||||
|
||||
async _deleteDictionarySettings(dictionaryTitle) {
|
||||
const optionsFull = await this._settingsController.getOptionsFull();
|
||||
const {profiles} = optionsFull;
|
||||
const targets = [];
|
||||
for (let i = 0, ii = profiles.length; i < ii; ++i) {
|
||||
const {options: {dictionaries}} = profiles[i];
|
||||
if (Object.prototype.hasOwnProperty.call(dictionaries, dictionaryTitle)) {
|
||||
const path = ObjectPropertyAccessor.getPathString(['profiles', i, 'options', 'dictionaries', dictionaryTitle]);
|
||||
targets.push({action: 'delete', path});
|
||||
}
|
||||
}
|
||||
await this._settingsController.modifyGlobalSettings(targets);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user