diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-08-30 19:38:36 -0400 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-09-28 21:54:18 -0400 |
commit | 664a318d7f5062bd397a8f40241c476dd3107f47 (patch) | |
tree | caa95a583762fd95b9f8d028be4ea3ac223cedc2 /ext/bg/js/translator.js | |
parent | a4f8a459deda49af36d46cd93d9ff92c8f98c8c9 (diff) |
Use non-async function for cache lookups
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r-- | ext/bg/js/translator.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 7b952622..21f40fe9 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -298,15 +298,13 @@ class Translator { const tags = []; for (const name of names) { const base = Translator.getNameBase(name); - const meta = await this.database.findTagForTitle(base, title); - - const tag = {name}; - for (const prop in meta || {}) { - if (prop !== 'name') { - tag[prop] = meta[prop]; - } + let meta = this.database.findTagForTitleCached(base, title); + if (typeof meta === 'undefined') { + meta = await this.database.findTagForTitle(base, title); } + const tag = Object.assign({}, meta !== null ? meta : {}, {name}); + tags.push(dictTagSanitize(tag)); } @@ -317,16 +315,18 @@ class Translator { const stats = {}; for (const name in items) { const base = Translator.getNameBase(name); - const meta = await this.database.findTagForTitle(base, title); - const group = stats[meta.category] = stats[meta.category] || []; - - const stat = {name, value: items[name]}; - for (const prop in meta || {}) { - if (prop !== 'name') { - stat[prop] = meta[prop]; + let meta = this.database.findTagForTitleCached(base, title); + if (typeof meta === 'undefined') { + meta = await this.database.findTagForTitle(base, title); + if (meta === null) { + continue; } } + const group = stats[meta.category] = stats[meta.category] || []; + + const stat = Object.assign({}, meta, {name, value: items[name]}); + group.push(dictTagSanitize(stat)); } |