aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/backend.js18
-rw-r--r--ext/bg/js/dictionary-database.js (renamed from ext/bg/js/database.js)2
-rw-r--r--ext/bg/js/dictionary-importer.js12
3 files changed, 16 insertions, 16 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 547b32d0..4791bfb5 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -21,7 +21,7 @@
* AudioSystem
* AudioUriBuilder
* ClipboardMonitor
- * Database
+ * DictionaryDatabase
* DictionaryImporter
* Environment
* JsonSchema
@@ -43,9 +43,9 @@
class Backend {
constructor() {
this._environment = new Environment();
- this._database = new Database();
+ this._dictionaryDatabase = new DictionaryDatabase();
this._dictionaryImporter = new DictionaryImporter();
- this._translator = new Translator(this._database);
+ this._translator = new Translator(this._dictionaryDatabase);
this._anki = new AnkiConnect();
this._mecab = new Mecab();
this._clipboardMonitor = new ClipboardMonitor({getClipboard: this._onApiClipboardGet.bind(this)});
@@ -193,7 +193,7 @@ class Backend {
await this._environment.prepare();
try {
- await this._database.prepare();
+ await this._dictionaryDatabase.prepare();
} catch (e) {
yomichan.logError(e);
}
@@ -709,11 +709,11 @@ class Backend {
async _onApiPurgeDatabase() {
this._translator.clearDatabaseCaches();
- await this._database.purge();
+ await this._dictionaryDatabase.purge();
}
async _onApiGetMedia({targets}) {
- return await this._database.getMedia(targets);
+ return await this._dictionaryDatabase.getMedia(targets);
}
_onApiLog({error, level, context}) {
@@ -747,12 +747,12 @@ class Backend {
}
async _onApiImportDictionaryArchive({archiveContent, details}, sender, onProgress) {
- return await this._dictionaryImporter.import(this._database, archiveContent, details, onProgress);
+ return await this._dictionaryImporter.import(this._dictionaryDatabase, archiveContent, details, onProgress);
}
async _onApiDeleteDictionary({dictionaryName}, sender, onProgress) {
this._translator.clearDatabaseCaches();
- await this._database.deleteDictionary(dictionaryName, {rate: 1000}, onProgress);
+ await this._dictionaryDatabase.deleteDictionary(dictionaryName, {rate: 1000}, onProgress);
}
async _onApiModifySettings({targets, source}) {
@@ -966,7 +966,7 @@ class Backend {
}
async _importDictionary(archiveSource, onProgress, details) {
- return await this._dictionaryImporter.import(this._database, archiveSource, onProgress, details);
+ return await this._dictionaryImporter.import(this._dictionaryDatabase, archiveSource, onProgress, details);
}
async _textParseScanning(text, options) {
diff --git a/ext/bg/js/database.js b/ext/bg/js/dictionary-database.js
index 47f1ebdd..c48320cd 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/dictionary-database.js
@@ -20,7 +20,7 @@
* dictFieldSplit
*/
-class Database {
+class DictionaryDatabase {
constructor() {
this._db = new GenericDatabase();
this._dbName = 'dict';
diff --git a/ext/bg/js/dictionary-importer.js b/ext/bg/js/dictionary-importer.js
index 10e30cec..12f3129d 100644
--- a/ext/bg/js/dictionary-importer.js
+++ b/ext/bg/js/dictionary-importer.js
@@ -27,11 +27,11 @@ class DictionaryImporter {
this._schemas = new Map();
}
- async import(database, archiveSource, details, onProgress) {
- if (!database) {
+ async import(dictionaryDatabase, archiveSource, details, onProgress) {
+ if (!dictionaryDatabase) {
throw new Error('Invalid database');
}
- if (!database.isPrepared()) {
+ if (!dictionaryDatabase.isPrepared()) {
throw new Error('Database is not ready');
}
@@ -60,7 +60,7 @@ class DictionaryImporter {
}
// Verify database is not already imported
- if (await database.dictionaryExists(dictionaryTitle)) {
+ if (await dictionaryDatabase.dictionaryExists(dictionaryTitle)) {
throw new Error('Dictionary is already imported');
}
@@ -168,7 +168,7 @@ class DictionaryImporter {
// Add dictionary
const summary = this._createSummary(dictionaryTitle, version, index, {prefixWildcardsSupported});
- database.bulkAdd('dictionaries', [summary], 0, 1);
+ dictionaryDatabase.bulkAdd('dictionaries', [summary], 0, 1);
// Add data
const errors = [];
@@ -188,7 +188,7 @@ class DictionaryImporter {
const count = Math.min(maxTransactionLength, ii - i);
try {
- await database.bulkAdd(objectStoreName, entries, i, count);
+ await dictionaryDatabase.bulkAdd(objectStoreName, entries, i, count);
} catch (e) {
errors.push(errorToJson(e));
}