firmware: "fix" the issue of user clicking check after clicking check from dashboard

We could move the check to backend() at the risk of breaking firmware upgrades on
errors.  Breaking the auto-check seems like the lesser evil.

In reality you can always go back to the status tab and re-create the issue by
clicking check for updates again after already having it clicked.  That is why the
page actually switches to the updates tab on click.  The update click is also delayed
to give the status call to fill the status tab first which immitates a normal page
render.

The issue actually appears because:

1. Backend options are detached and are dispatched, but since they run in the backround
   we don't return any feedback because we don't have it.  This then...
2. ... creates a parallel chain of trackStatus() calls which eventually reports the same
   modal.

The issue only appears when no updates are found or triggering a separate error modal.
When updates are found this is handled gracefully.

Making the modals and errors static seems like overkill as well.

Keeping friction and magic out of this page is important too.
This commit is contained in:
Franco Fichtner 2025-03-31 16:58:46 +02:00
parent 3f1ed2dff5
commit f698e25cbb

View File

@ -130,7 +130,7 @@
* perform backend action and install poller to update status
*/
function backend(type) {
$.upgrade_check = type == 'check'
$.upgrade_check = type == 'check';
$('#update_status').html('');
$('#updatelist').hide();
@ -647,7 +647,13 @@
backend('audit');
} else if (window.location.hash == '#checkupdate') {
// dashboard link: run check automatically after delay
setTimeout(function () { backend('check'); }, 2000);
setTimeout(function () {
ajaxGet('/api/core/firmware/running', {}, function(data, status) {
if (data['status'] != 'busy') {
backend('check');
}
});
}, 2000);
}
});