diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-07 19:27:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-07 19:27:58 -0400 |
commit | ac1ecb35ee010969b683188501ea473c2575f65d (patch) | |
tree | c169e5c97287f9dbe4c6a1760bac80f019d76e44 /ext/bg/js/dictionary-importer.js | |
parent | 623469272ed88680d767445b0290de0de6c75a6f (diff) | |
parent | dd9d50bfc194aa4c3d8e99188cfac0214476f868 (diff) |
Merge pull request #433 from toasted-nutbread/extra-dictionary-information
Extra dictionary information
Diffstat (limited to 'ext/bg/js/dictionary-importer.js')
-rw-r--r-- | ext/bg/js/dictionary-importer.js | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/ext/bg/js/dictionary-importer.js b/ext/bg/js/dictionary-importer.js index 589e7656..f9e173ea 100644 --- a/ext/bg/js/dictionary-importer.js +++ b/ext/bg/js/dictionary-importer.js @@ -150,13 +150,7 @@ class DictionaryImporter { } // Add dictionary - const summary = { - title: dictionaryTitle, - revision: index.revision, - sequenced: index.sequenced, - version, - prefixWildcardsSupported - }; + const summary = this._createSummary(dictionaryTitle, version, index, {prefixWildcardsSupported}); database.bulkAdd('dictionaries', [summary], 0, 1); @@ -199,6 +193,25 @@ class DictionaryImporter { return {result: summary, errors}; } + _createSummary(dictionaryTitle, version, index, details) { + const summary = { + title: dictionaryTitle, + revision: index.revision, + sequenced: index.sequenced, + version + }; + + const {author, url, description, attribution} = index; + if (typeof author === 'string') { summary.author = author; } + if (typeof url === 'string') { summary.url = url; } + if (typeof description === 'string') { summary.description = description; } + if (typeof attribution === 'string') { summary.attribution = attribution; } + + Object.assign(summary, details); + + return summary; + } + async _getSchema(fileName) { let schemaPromise = this._schemas.get(fileName); if (typeof schemaPromise !== 'undefined') { |