diff options
Diffstat (limited to 'ext/js/language')
-rw-r--r-- | ext/js/language/dictionary-worker-handler.js | 12 | ||||
-rw-r--r-- | ext/js/language/dictionary-worker.js | 4 |
2 files changed, 16 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(); diff --git a/ext/js/language/dictionary-worker.js b/ext/js/language/dictionary-worker.js index 4adfdaec..92faa3dc 100644 --- a/ext/js/language/dictionary-worker.js +++ b/ext/js/language/dictionary-worker.js @@ -38,6 +38,10 @@ class DictionaryWorker { return this._invoke('deleteDictionary', {dictionaryTitle}, [], onProgress); } + getDictionaryCounts(dictionaryNames, getTotal) { + return this._invoke('getDictionaryCounts', {dictionaryNames, getTotal}, [], null); + } + // Private _invoke(action, params, transfer, onProgress, formatResult) { |