Skip to content

Commit

Permalink
Disable no update button (#1354)
Browse files Browse the repository at this point in the history
* disable no updates button

* check if has update
  • Loading branch information
Casheeew authored Aug 25, 2024
1 parent 2f1b77c commit fb7f116
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ext/js/pages/settings/dictionary-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -958,17 +958,22 @@ 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);

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;
}
}
Expand Down

0 comments on commit fb7f116

Please sign in to comment.