diff --git a/public/js/system-status.js b/public/js/system-status.js index 3487561..d80b46e 100644 --- a/public/js/system-status.js +++ b/public/js/system-status.js @@ -312,6 +312,15 @@ function initSystemStatus() { return; } + // Disable test mode whenever we try to apply an update + localStorage.setItem('showUpdateButton', 'false'); + + // Update toggle button text if it exists + const testToggle = document.getElementById('toggle-test-update-button'); + if (testToggle) { + testToggle.innerText = 'Enable Test Update'; + } + // Show loading state on both update buttons // Original button if (updateButton) { @@ -544,8 +553,19 @@ function initSystemStatus() { console.log('Manual refresh result:', data); if (data.status === 'success') { - // Show notification about current status - if (data.data && data.data.updateAvailable) { + // Check if we're in test mode + const isTestMode = localStorage.getItem('showUpdateButton') === 'true'; + + // If test mode is enabled but update says no update available, disable test mode + if (isTestMode && data.data && !data.data.updateAvailable) { + localStorage.setItem('showUpdateButton', 'false'); + testToggle.innerText = 'Enable Test Update'; + showNotification('Test mode has been disabled - no real update is available', 'info'); + hideUpdateAlert(); + showNotification(`Current version: ${data.data.currentVersion}. You are up to date.`, 'success'); + } + // Regular update handling + else if (data.data && data.data.updateAvailable) { showUpdateAlert(data.data.currentVersion, data.data.remoteVersion); showNotification(`Update is available: ${data.data.currentVersion} → ${data.data.remoteVersion}`, 'info'); } else { @@ -588,8 +608,26 @@ function initSystemStatus() { if (newSetting) { // If enabling test mode, force show update button showUpdateAlert('2.0.10', '2.1.0-test'); - updateStatusElement.innerHTML = ' Update available'; - showNotification('Test update button enabled', 'info'); + updateStatusElement.innerHTML = ' Update available (TEST MODE)'; + + // Add test mode indicator to floating notification + const floatingNotification = document.getElementById('floating-update-notification'); + if (floatingNotification) { + const testBadge = document.createElement('div'); + testBadge.style.backgroundColor = 'orange'; + testBadge.style.color = 'black'; + testBadge.style.padding = '3px 8px'; + testBadge.style.borderRadius = '4px'; + testBadge.style.fontWeight = 'bold'; + testBadge.style.marginBottom = '5px'; + testBadge.style.fontSize = '12px'; + testBadge.textContent = 'TEST MODE - NOT A REAL UPDATE'; + + // Insert at the top of the notification + floatingNotification.insertBefore(testBadge, floatingNotification.firstChild); + } + + showNotification('TEST MODE ENABLED - This is not a real update', 'warning'); } else { // If disabling test mode, check for real updates hideUpdateAlert();