diff --git a/public/js/system-status.js b/public/js/system-status.js index d80b46e..23ec3bd 100644 --- a/public/js/system-status.js +++ b/public/js/system-status.js @@ -593,6 +593,14 @@ function initSystemStatus() { // Initialize based on current localStorage setting const isTestMode = localStorage.getItem('showUpdateButton') === 'true'; + // If test mode is enabled but we have a version mismatch, update the stored version + if (isTestMode && versionElement && versionElement.textContent) { + const currentVersion = versionElement.textContent.trim(); + if (localStorage.getItem(CURRENT_VERSION_KEY) !== currentVersion) { + localStorage.setItem(CURRENT_VERSION_KEY, currentVersion); + } + } + // Update toggle text testToggle.innerText = isTestMode ? 'Disable Test Update' : 'Enable Test Update'; @@ -606,8 +614,14 @@ function initSystemStatus() { testToggle.innerText = newSetting ? 'Disable Test Update' : 'Enable Test Update'; if (newSetting) { + // Get the current version from the version element + let currentVersion = '2.0.11'; // Default fallback + if (versionElement && versionElement.textContent) { + currentVersion = versionElement.textContent.trim(); + } + // If enabling test mode, force show update button - showUpdateAlert('2.0.10', '2.1.0-test'); + showUpdateAlert(currentVersion, '2.1.0-test'); updateStatusElement.innerHTML = ' Update available (TEST MODE)'; // Add test mode indicator to floating notification @@ -657,9 +671,20 @@ function initSystemStatus() { const isUpdateAvailable = localStorage.getItem(UPDATE_KEY) === 'true'; if (isUpdateAvailable) { - const currentVersion = localStorage.getItem(CURRENT_VERSION_KEY); + // Get the most current version + let currentVersion = localStorage.getItem(CURRENT_VERSION_KEY); const remoteVersion = localStorage.getItem(REMOTE_VERSION_KEY); + // If we have the version element on screen, use that as the source of truth + if (versionElement && versionElement.textContent) { + const displayedVersion = versionElement.textContent.trim(); + // Update stored version if different + if (displayedVersion !== currentVersion) { + localStorage.setItem(CURRENT_VERSION_KEY, displayedVersion); + currentVersion = displayedVersion; + } + } + if (currentVersion && remoteVersion) { // Check floating notification const floatingNotification = document.getElementById('floating-update-notification');