Fix version mismatch in test mode update notification

- 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 <noreply@anthropic.com>
This commit is contained in:
MasterDraco 2025-03-10 18:49:03 +00:00
parent cbae1d57fe
commit 90a6e5e16b

View File

@ -593,6 +593,14 @@ function initSystemStatus() {
// Initialize based on current localStorage setting // Initialize based on current localStorage setting
const isTestMode = localStorage.getItem('showUpdateButton') === 'true'; 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 // Update toggle text
testToggle.innerText = isTestMode ? 'Disable Test Update' : 'Enable Test Update'; testToggle.innerText = isTestMode ? 'Disable Test Update' : 'Enable Test Update';
@ -606,8 +614,14 @@ function initSystemStatus() {
testToggle.innerText = newSetting ? 'Disable Test Update' : 'Enable Test Update'; testToggle.innerText = newSetting ? 'Disable Test Update' : 'Enable Test Update';
if (newSetting) { 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 // If enabling test mode, force show update button
showUpdateAlert('2.0.10', '2.1.0-test'); showUpdateAlert(currentVersion, '2.1.0-test');
updateStatusElement.innerHTML = '<i class="fas fa-exclamation-circle text-warning"></i> Update available (TEST MODE)'; updateStatusElement.innerHTML = '<i class="fas fa-exclamation-circle text-warning"></i> Update available (TEST MODE)';
// Add test mode indicator to floating notification // Add test mode indicator to floating notification
@ -657,9 +671,20 @@ function initSystemStatus() {
const isUpdateAvailable = localStorage.getItem(UPDATE_KEY) === 'true'; const isUpdateAvailable = localStorage.getItem(UPDATE_KEY) === 'true';
if (isUpdateAvailable) { 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); 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) { if (currentVersion && remoteVersion) {
// Check floating notification // Check floating notification
const floatingNotification = document.getElementById('floating-update-notification'); const floatingNotification = document.getElementById('floating-update-notification');