summaryrefslogtreecommitdiff
path: root/ext/js/pages/settings
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/pages/settings')
-rw-r--r--ext/js/pages/settings/dictionary-import-controller.js36
1 files changed, 11 insertions, 25 deletions
diff --git a/ext/js/pages/settings/dictionary-import-controller.js b/ext/js/pages/settings/dictionary-import-controller.js
index 128e18cb..5e51a48a 100644
--- a/ext/js/pages/settings/dictionary-import-controller.js
+++ b/ext/js/pages/settings/dictionary-import-controller.js
@@ -17,9 +17,7 @@
/* global
* DictionaryController
- * DictionaryDatabase
- * DictionaryImporter
- * DictionaryImporterMediaLoader
+ * DictionaryImporterThreaded
*/
class DictionaryImportController {
@@ -183,22 +181,16 @@ class DictionaryImportController {
}
async _importDictionary(file, importDetails, onProgress) {
- const dictionaryDatabase = await this._getPreparedDictionaryDatabase();
- try {
- const dictionaryImporterMediaLoader = new DictionaryImporterMediaLoader();
- const dictionaryImporter = new DictionaryImporter(dictionaryImporterMediaLoader);
- const archiveContent = await this._readFile(file);
- const {result, errors} = await dictionaryImporter.importDictionary(dictionaryDatabase, archiveContent, importDetails, onProgress);
- yomichan.api.triggerDatabaseUpdated('dictionary', 'import');
- const errors2 = await this._addDictionarySettings(result.sequenced, result.title);
-
- if (errors.length > 0) {
- const allErrors = [...errors, ...errors2];
- allErrors.push(new Error(`Dictionary may not have been imported properly: ${allErrors.length} error${allErrors.length === 1 ? '' : 's'} reported.`));
- this._showErrors(allErrors);
- }
- } finally {
- dictionaryDatabase.close();
+ const dictionaryImporter = new DictionaryImporterThreaded();
+ const archiveContent = await this._readFile(file);
+ const {result, errors} = await dictionaryImporter.importDictionary(archiveContent, importDetails, onProgress);
+ yomichan.api.triggerDatabaseUpdated('dictionary', 'import');
+ const errors2 = await this._addDictionarySettings(result.sequenced, result.title);
+
+ if (errors.length > 0) {
+ const allErrors = [...errors, ...errors2];
+ allErrors.push(new Error(`Dictionary may not have been imported properly: ${allErrors.length} error${allErrors.length === 1 ? '' : 's'} reported.`));
+ this._showErrors(allErrors);
}
}
@@ -311,12 +303,6 @@ class DictionaryImportController {
}
}
- async _getPreparedDictionaryDatabase() {
- const dictionaryDatabase = new DictionaryDatabase();
- await dictionaryDatabase.prepare();
- return dictionaryDatabase;
- }
-
async _modifyGlobalSettings(targets) {
const results = await this._settingsController.modifyGlobalSettings(targets);
const errors = [];