From 1b97629cd8014d7523a12ae857305e65a6d06672 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 5 Apr 2020 14:45:54 -0400 Subject: Store new dictionary data --- ext/bg/js/dictionary-importer.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'ext/bg') 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') { -- cgit v1.2.3