aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-08-23 20:53:11 -0700
committerAlex Yatskov <alex@foosoft.net>2016-08-23 20:53:11 -0700
commit6366d9bd8e5758d631e5bba14b2c892e0b27c474 (patch)
tree33d09a8912011ee3c23820302be4bc8ee9a6cf30 /ext/bg/js/dictionary.js
parentf106b64876c975237e8c8bb51518ab53d2a9d2fc (diff)
WIP
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js28
1 files changed, 14 insertions, 14 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index dd46064a..44e97752 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -38,8 +38,8 @@ class Dictionary {
this.db = new Dexie('dict');
this.db.version(1).stores({
terms: '++id,expression,reading',
- entities: '++id,name',
- kanji: '++id,character'
+ entities: '++,name',
+ kanji: '++,character'
});
return this.db;
@@ -125,24 +125,24 @@ class Dictionary {
for (let i = 0; i < index.refs; ++i) {
const refUrl = `${indexDir}/ref_${i}.json`;
- loaders.push(
- Dictionary.loadJson(refUrl).then((refs) => {
+ loaders.push(() => {
+ return Dictionary.loadJson(refUrl).then((refs) => {
const rows = [];
- for (const [e, r, t, ...g] of refs) {
- rows.push({
- 'expression': e,
- 'reading': r,
- 'tags': t,
- 'glossary': g
- });
+ for (const [expression, reading, tags, ...glossary] of refs) {
+ rows.push({expression, reading, tags, glossary});
}
return this.db.terms.bulkAdd(rows);
- })
- );
+ });
+ });
}
- return Promise.all(loaders);
+ let chain = Promise.resolve();
+ for (const loader of loaders) {
+ chain = chain.then(loader);
+ }
+
+ return chain;
});
});
}