Skip to content

Commit

Permalink
move promise to _deleteDictionaryInternal
Browse files Browse the repository at this point in the history
  • Loading branch information
khaitruong922 committed Nov 6, 2024
1 parent 97ba5d7 commit 40fcfe0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ext/js/pages/settings/dictionary-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ export class DictionaryController {
} else if (task.type === 'update') {
await this._updateDictionary(task.dictionaryTitle, task.downloadUrl);
}
console.log('Task done');

Check failure on line 1108 in ext/js/pages/settings/dictionary-controller.js

View workflow job for this annotation

GitHub Actions / Static Analysis

Unexpected console statement
void this._dictionaryTaskQueue.shift();
}
this._isTaskQueueRunning = false;
Expand Down Expand Up @@ -1150,12 +1151,8 @@ export class DictionaryController {
for (const label of infoLabels) { label.textContent = 'Deleting dictionary...'; }
if (statusFooter !== null) { statusFooter.setTaskActive(progressSelector, true); }

/** @type {import('core').DeferredPromiseDetails<void>} */
const {promise: dictionariesUpdatePromise, resolve} = deferPromise();
this._onDictionariesUpdate = resolve;
await this._deleteDictionaryInternal(dictionaryTitle, onProgress);
await this._deleteDictionarySettings(dictionaryTitle);
await dictionariesUpdatePromise;
this._onDictionariesUpdate = null;
} catch (e) {
log.error(e);
Expand Down Expand Up @@ -1219,7 +1216,12 @@ export class DictionaryController {
*/
async _deleteDictionaryInternal(dictionaryTitle, onProgress) {
await new DictionaryWorker().deleteDictionary(dictionaryTitle, onProgress);
/** @type {import('core').DeferredPromiseDetails<void>} */
const {promise: dictionariesUpdatePromise, resolve} = deferPromise();
this._onDictionariesUpdate = resolve;
void this._settingsController.application.api.triggerDatabaseUpdated('dictionary', 'delete');
await dictionariesUpdatePromise;
this._onDictionariesUpdate = null;
}

/**
Expand Down

0 comments on commit 40fcfe0

Please sign in to comment.