From 290894da6cc8fad4b559725716cb9c2e6324353f Mon Sep 17 00:00:00 2001 From: Khai Truong Date: Wed, 11 Sep 2024 11:28:17 +0700 Subject: [PATCH] disable download button if in queue --- ext/js/pages/settings/dictionary-import-controller.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/js/pages/settings/dictionary-import-controller.js b/ext/js/pages/settings/dictionary-import-controller.js index 8ab49aedc2..b663f15aa8 100644 --- a/ext/js/pages/settings/dictionary-import-controller.js +++ b/ext/js/pages/settings/dictionary-import-controller.js @@ -120,7 +120,7 @@ export class DictionaryImportController { while (this._recommendedDictionaryQueue.length > 0) { this._recommendedDictionaryActiveImport = true; try { - const url = this._recommendedDictionaryQueue.shift(); + const url = this._recommendedDictionaryQueue[0]; if (!url) { continue; } const importProgressTracker = new ImportProgressTracker(this._getUrlImportSteps(), 1); @@ -129,6 +129,7 @@ export class DictionaryImportController { this._generateFilesFromUrls([url], onProgress), importProgressTracker, ); + void this._recommendedDictionaryQueue.shift(); } catch (error) { log.error(error); } @@ -219,7 +220,11 @@ export class DictionaryImportController { const homepage = querySelectorNotNull(template, '.homepage'); /** @type {HTMLButtonElement} */ const button = querySelectorNotNull(template, '.action-button[data-action=import-recommended-dictionary]'); - button.disabled = installedDictionaryNames.has(dictionary.name) || installedDictionaryDownloadUrls.has(dictionary.downloadUrl); + button.disabled = ( + installedDictionaryNames.has(dictionary.name) || + installedDictionaryDownloadUrls.has(dictionary.downloadUrl) || + this._recommendedDictionaryQueue.includes(dictionary.downloadUrl) + ); const urlAttribute = document.createAttribute('data-import-url'); urlAttribute.value = dictionary.downloadUrl;