From f698e25cbbc3d41b20be99397ae22bb0d4f03d93 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 31 Mar 2025 16:58:46 +0200 Subject: [PATCH] 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. --- src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt b/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt index f7319b5ab..8477362df 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt @@ -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); } });