Skip to content

Commit

Permalink
disable download button if in queue
Browse files Browse the repository at this point in the history
  • Loading branch information
khaitruong922 committed Sep 11, 2024
1 parent 61b7470 commit 290894d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ext/js/pages/settings/dictionary-import-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -129,6 +129,7 @@ export class DictionaryImportController {
this._generateFilesFromUrls([url], onProgress),
importProgressTracker,
);
void this._recommendedDictionaryQueue.shift();
} catch (error) {
log.error(error);
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 290894d

Please sign in to comment.