From 4839503d540adf7b48d0b1d337bef7b7c9b890ad Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 14 Aug 2021 12:41:58 -0400 Subject: Threaded dictionary delete (#1895) * Generalize dictionary worker * Add deleteDictionary functionality * Update DictionaryController to use DictionaryDatabaseModifier * Fix incorrect result handling --- ext/js/pages/settings/dictionary-controller.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'ext/js/pages/settings') diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index 47b256d8..8df4b6bd 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -16,7 +16,7 @@ */ /* global - * DictionaryDatabase + * DictionaryDatabaseModifier */ class DictionaryEntry { @@ -679,19 +679,9 @@ class DictionaryController { } async _deleteDictionaryInternal(dictionaryTitle, onProgress) { - const dictionaryDatabase = await this._getPreparedDictionaryDatabase(); - try { - await dictionaryDatabase.deleteDictionary(dictionaryTitle, {rate: 1000}, onProgress); - yomichan.api.triggerDatabaseUpdated('dictionary', 'delete'); - } finally { - dictionaryDatabase.close(); - } - } - - async _getPreparedDictionaryDatabase() { - const dictionaryDatabase = new DictionaryDatabase(); - await dictionaryDatabase.prepare(); - return dictionaryDatabase; + const dictionaryDatabaseModifier = new DictionaryDatabaseModifier(); + await dictionaryDatabaseModifier.deleteDictionary(dictionaryTitle, onProgress); + yomichan.api.triggerDatabaseUpdated('dictionary', 'delete'); } async _deleteDictionarySettings(dictionaryTitle) { -- cgit v1.2.3