summaryrefslogtreecommitdiff
path: root/ext/bg/js/database.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-11-13 11:37:54 -0800
committerAlex Yatskov <alex@foosoft.net>2016-11-13 11:37:54 -0800
commit7598de2234393433e98c9af3c312a1bcfd82c32f (patch)
tree46edf8a00733bd0d9d308758e8d1256f30d44e85 /ext/bg/js/database.js
parent320a82146b8673dcc1f5ba4717a8948e8f114010 (diff)
Cleanup
Diffstat (limited to 'ext/bg/js/database.js')
-rw-r--r--ext/bg/js/database.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index f3a9732c..4c8703c3 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -133,7 +133,7 @@ class Database {
const promises = [];
for (const dictionary of dictionaries) {
- if (this.entities.hasOwnProperty(dictionary)) {
+ if (this.entities[dictionary]) {
promises.push(Promise.resolve(this.entities[dictionary]));
} else {
const entities = this.entities[dictionary] = {};
@@ -146,14 +146,14 @@ class Database {
}
return Promise.all(promises).then(results => {
- const entries = {};
+ const entities = {};
for (const result of results) {
for (const name in result) {
- entries[name] = result[name];
+ entities[name] = result[name];
}
}
- return entries;
+ return entities;
});
}
@@ -243,7 +243,9 @@ class Database {
return Promise.reject('database not initialized');
}
+ let summary = null;
const indexLoaded = (title, version, entities, hasTerms, hasKanji) => {
+ summary = {title, hasTerms, hasKanji, version};
return this.db.dictionaries.where('title').equals(title).count().then(count => {
if (count > 0) {
return Promise.reject(`dictionary "${title}" is already imported`);
@@ -301,6 +303,6 @@ class Database {
});
};
- return importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded);
+ return importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded).then(() => summary);
}
}