diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-09-19 17:17:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-19 17:17:33 -0400 |
commit | a2e6de84af6a304cf586759fe8a0d50d4d94785e (patch) | |
tree | bac23d15f0f048510b1cd67cd0331f4ffde15456 /ext/bg/js/settings | |
parent | 1078ab99b7a9d082ee36cbed69c8cb154db318b6 (diff) |
Dictionary delete improvements (#844)
* Change where clearDatabaseCaches occurs
* Move dictionary deletion into the settings page
* Remove api.deleteDictionary
Diffstat (limited to 'ext/bg/js/settings')
-rw-r--r-- | ext/bg/js/settings/dictionary-controller.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ext/bg/js/settings/dictionary-controller.js b/ext/bg/js/settings/dictionary-controller.js index afc198e2..e5a07f9d 100644 --- a/ext/bg/js/settings/dictionary-controller.js +++ b/ext/bg/js/settings/dictionary-controller.js @@ -16,6 +16,7 @@ */ /* global + * DictionaryDatabase * Modal * ObjectPropertyAccessor * api @@ -349,7 +350,7 @@ class DictionaryController { progressBar.style.width = `${percent}%`; }; - await api.deleteDictionary(dictionaryTitle, onProgress); + await this._deleteDictionaryInternal(dictionaryTitle, onProgress); } catch (e) { yomichan.logError(e); } finally { @@ -372,4 +373,20 @@ class DictionaryController { const content = document.importNode(template.content, true); return content.firstChild; } + + async _deleteDictionaryInternal(dictionaryTitle, onProgress) { + const dictionaryDatabase = await this._getPreparedDictionaryDatabase(); + try { + await dictionaryDatabase.deleteDictionary(dictionaryTitle, {rate: 1000}, onProgress); + api.triggerDatabaseUpdated('dictionary', 'delete'); + } finally { + dictionaryDatabase.close(); + } + } + + async _getPreparedDictionaryDatabase() { + const dictionaryDatabase = new DictionaryDatabase(); + await dictionaryDatabase.prepare(); + return dictionaryDatabase; + } } |