aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/dictionary-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/settings/dictionary-controller.js')
-rw-r--r--ext/bg/js/settings/dictionary-controller.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/ext/bg/js/settings/dictionary-controller.js b/ext/bg/js/settings/dictionary-controller.js
index afc198e2..e5a07f9d 100644
--- a/ext/bg/js/settings/dictionary-controller.js
+++ b/ext/bg/js/settings/dictionary-controller.js
@@ -16,6 +16,7 @@
*/
/* global
+ * DictionaryDatabase
* Modal
* ObjectPropertyAccessor
* api
@@ -349,7 +350,7 @@ class DictionaryController {
progressBar.style.width = `${percent}%`;
};
- await api.deleteDictionary(dictionaryTitle, onProgress);
+ await this._deleteDictionaryInternal(dictionaryTitle, onProgress);
} catch (e) {
yomichan.logError(e);
} finally {
@@ -372,4 +373,20 @@ class DictionaryController {
const content = document.importNode(template.content, true);
return content.firstChild;
}
+
+ async _deleteDictionaryInternal(dictionaryTitle, onProgress) {
+ const dictionaryDatabase = await this._getPreparedDictionaryDatabase();
+ try {
+ await dictionaryDatabase.deleteDictionary(dictionaryTitle, {rate: 1000}, onProgress);
+ api.triggerDatabaseUpdated('dictionary', 'delete');
+ } finally {
+ dictionaryDatabase.close();
+ }
+ }
+
+ async _getPreparedDictionaryDatabase() {
+ const dictionaryDatabase = new DictionaryDatabase();
+ await dictionaryDatabase.prepare();
+ return dictionaryDatabase;
+ }
}