From 90a6e5e16b95c67afbcb67c062cf4ff47cf3d8d1 Mon Sep 17 00:00:00 2001 From: MasterDraco Date: Mon, 10 Mar 2025 18:49:03 +0000 Subject: [PATCH] Fix version mismatch in test mode update notification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updated test mode to use current version number from system status - Added version synchronization between displayed and stored values - Enhanced forceShowUpdateButton to use the most current version - Added version comparison to detect and fix mismatches - Used the displayed version as the source of truth - Implemented automatic version correction in localStorage - Fixed hardcoded version number in test mode - Improved version consistency across the application 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- public/js/system-status.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) 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');