Skip to content

Commit

Permalink
Fix recommended dictionary download queue (#1410)
Browse files Browse the repository at this point in the history
* fix queue not working

* disable download button if in queue

* remove useless void
  • Loading branch information
khaitruong922 authored Sep 12, 2024
1 parent e3ad27a commit 5f5629b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ext/js/pages/settings/dictionary-import-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ 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);
const onProgress = importProgressTracker.onProgress.bind(importProgressTracker);
void this._importDictionaries(
await this._importDictionaries(
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 5f5629b

Please sign in to comment.