aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-08-29 19:51:37 -0700
committerAlex Yatskov <alex@foosoft.net>2016-08-29 19:51:37 -0700
commitc55ba3b2be267d9dc616bda1a293d136c63cd639 (patch)
tree7b4471e5dc9b6fcb118fc67e52e5634552d76138 /ext
parent9462bc397b45aef0034f5ef8d11294125198581b (diff)
WIP
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/dictionary.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index b7b7039c..7cfa58a8 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -19,8 +19,8 @@
class Dictionary {
constructor() {
- this.db = null;
this.entities = null;
+ this.db = new Dexie('dict');
}
existsDb() {
@@ -29,8 +29,6 @@ class Dictionary {
initDb() {
this.entities = null;
-
- this.db = new Dexie('dict');
this.db.version(1).stores({
terms: '++id,expression,reading',
entities: '++,name',
@@ -46,11 +44,16 @@ class Dictionary {
reading: row.reading,
tags: row.tags.split(' '),
glossary: row.glossary,
- entities: this.entities,
id: row.id
});
}).then(() => {
- return Promise.resolve(results);
+ return this.getEntities();
+ }).then((entities) => {
+ for (const result of results) {
+ result.entities = entities;
+ }
+
+ return results;
});
}
@@ -67,9 +70,9 @@ class Dictionary {
});
}
- getEntities() {
+ getEntities(tags) {
if (this.entities !== null) {
- return Promise.resolve(this.entities);
+ return this.entities;
}
return this.db.entities.toArray((rows) => {
@@ -77,8 +80,8 @@ class Dictionary {
for (const row of rows) {
this.entities[row.name] = row.value;
}
- }).then(() => {
- return Promise.resolve(this.entities);
+
+ return this.entities;
});
}