diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-08-28 14:30:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-28 14:30:50 -0400 |
commit | 87fbb3c01ccc7e14b5fa29d6126ef684ceb558a9 (patch) | |
tree | 7cdadb38bc3b03fdfeab2d79547215d7246bb71e /ext/js/language/dictionary-worker-handler.js | |
parent | 74709296e557dfeab2e465f8bd53681934fe8040 (diff) |
Dictionary worker updates (#1914)
* Add support for running getDictionaryCounts via DictionaryWorker
* Run dictionary integrity checks on a separate thread
* Remove api.getDictionaryCounts
Diffstat (limited to 'ext/js/language/dictionary-worker-handler.js')
-rw-r--r-- | ext/js/language/dictionary-worker-handler.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ext/js/language/dictionary-worker-handler.js b/ext/js/language/dictionary-worker-handler.js index 88150f50..1d6b4aab 100644 --- a/ext/js/language/dictionary-worker-handler.js +++ b/ext/js/language/dictionary-worker-handler.js @@ -41,6 +41,9 @@ class DictionaryWorkerHandler { case 'deleteDictionary': this._onMessageWithProgress(params, this._deleteDictionary.bind(this)); break; + case 'getDictionaryCounts': + this._onMessageWithProgress(params, this._getDictionaryCounts.bind(this)); + break; case 'getImageResolution.response': this._mediaLoader.handleMessage(params); break; @@ -87,6 +90,15 @@ class DictionaryWorkerHandler { } } + async _getDictionaryCounts({dictionaryNames, getTotal}) { + const dictionaryDatabase = await this._getPreparedDictionaryDatabase(); + try { + return await dictionaryDatabase.getDictionaryCounts(dictionaryNames, getTotal); + } finally { + dictionaryDatabase.close(); + } + } + async _getPreparedDictionaryDatabase() { const dictionaryDatabase = new DictionaryDatabase(); await dictionaryDatabase.prepare(); |