From 06274345cb7aac51700f09474f0ff10eb8c279d9 Mon Sep 17 00:00:00 2001 From: Cashew Date: Mon, 26 Aug 2024 00:24:23 +0700 Subject: [PATCH] check if has update --- ext/js/pages/settings/dictionary-controller.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index 5ddace3b1c..1c6eb5678f 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -958,6 +958,7 @@ export class DictionaryController { /** */ async _checkForUpdates() { if (this._dictionaries === null || this._checkingIntegrity || this._checkingUpdates || this._isDeleting) { return; } + let hasUpdates; try { this._checkingUpdates = true; this._setButtonsEnabled(false); @@ -965,11 +966,12 @@ export class DictionaryController { const updateChecks = this._dictionaryEntries.map((entry) => entry.checkForUpdate()); const updateCount = (await Promise.all(updateChecks)).reduce((sum, value) => (sum + (value ? 1 : 0)), 0); if (this._checkUpdatesButton !== null) { - this._checkUpdatesButton.textContent = updateCount ? `${updateCount} update${updateCount > 1 ? 's' : ''}` : 'No updates'; + hasUpdates = !!updateCount; + this._checkUpdatesButton.textContent = hasUpdates ? `${updateCount} update${updateCount > 1 ? 's' : ''}` : 'No updates'; } } finally { this._setButtonsEnabled(true); - if (this._checkUpdatesButton !== null) { + if (this._checkUpdatesButton !== null && !hasUpdates) { this._checkUpdatesButton.disabled = true; } this._checkingUpdates = false;