From fb7f11698352c53ea1822ff90fa4793a92f93c54 Mon Sep 17 00:00:00 2001 From: Cashew <52880648+Casheeew@users.noreply.github.com> Date: Mon, 26 Aug 2024 04:09:30 +0700 Subject: [PATCH] Disable no update button (#1354) * disable no updates button * check if has update --- ext/js/pages/settings/dictionary-controller.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index 49dd865dd4..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,10 +966,14 @@ 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 && !hasUpdates) { + this._checkUpdatesButton.disabled = true; + } this._checkingUpdates = false; } }