diff --git a/public/index.html b/public/index.html
index 3a46ab1..62e8ca3 100644
--- a/public/index.html
+++ b/public/index.html
@@ -724,7 +724,10 @@
Update Available!
New version available
-
+
+
+
+
diff --git a/public/js/system-status.js b/public/js/system-status.js
index 63d3b05..3487561 100644
--- a/public/js/system-status.js
+++ b/public/js/system-status.js
@@ -275,6 +275,9 @@ function initSystemStatus() {
// No update available
updateStatusElement.innerHTML = ' Up to date';
hideUpdateAlert();
+
+ // Force reload system status to ensure version is current
+ setTimeout(() => loadSystemStatus(), 1000);
}
} else {
// Error status but with a response
@@ -405,6 +408,12 @@ function initSystemStatus() {
// Update page to show current version without reloading
loadSystemStatus();
+
+ // Double-check system status again after a delay to ensure version is updated
+ setTimeout(() => {
+ loadSystemStatus();
+ checkForUpdates(); // Run check again to update status text
+ }, 2000);
return;
}
@@ -516,6 +525,48 @@ function initSystemStatus() {
updateButton.addEventListener('click', applyUpdate);
}
+ // Add handler for floating refresh button
+ const floatingRefreshButton = document.getElementById('floating-refresh-button');
+ if (floatingRefreshButton) {
+ floatingRefreshButton.addEventListener('click', () => {
+ // Force a hard refresh of everything
+ floatingRefreshButton.textContent = 'Refreshing...';
+ floatingRefreshButton.disabled = true;
+
+ // Force reload system status
+ loadSystemStatus();
+
+ // Force a check without the test parameter to get real status
+ const realCheckUrl = `/api/system/check-updates?_=${new Date().getTime()}`;
+ fetch(realCheckUrl, { headers: authHeaders() })
+ .then(response => response.json())
+ .then(data => {
+ console.log('Manual refresh result:', data);
+
+ if (data.status === 'success') {
+ // Show notification about current status
+ 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 {
+ hideUpdateAlert();
+ showNotification(`Current version: ${data.data.currentVersion}. You are up to date.`, 'success');
+ }
+ }
+
+ // Re-enable button
+ floatingRefreshButton.textContent = 'Refresh Status';
+ floatingRefreshButton.disabled = false;
+ })
+ .catch(error => {
+ console.error('Error during manual refresh:', error);
+ floatingRefreshButton.textContent = 'Refresh Status';
+ floatingRefreshButton.disabled = false;
+ showNotification('Error checking update status', 'danger');
+ });
+ });
+ }
+
// Test mode toggle (for developers)
const testToggle = document.getElementById('toggle-test-update-button');
if (testToggle) {
diff --git a/server.js b/server.js
index 56a442b..245ba26 100644
--- a/server.js
+++ b/server.js
@@ -90,8 +90,20 @@ const JWT_SECRET = process.env.JWT_SECRET || 'transmission-rss-manager-secret';
const JWT_EXPIRY = '24h';
// Get the version from package.json (single source of truth)
-const PACKAGE_JSON = require('./package.json');
-const APP_VERSION = PACKAGE_JSON.version;
+// Re-read the package.json file each time to ensure we get the latest version
+const APP_VERSION = (() => {
+ try {
+ // Use synchronous file read to ensure we have the version before continuing
+ const packageJsonPath = path.join(__dirname, 'package.json');
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
+ return packageJson.version;
+ } catch (err) {
+ console.error('Error reading package.json version:', err);
+ // Fallback to requiring package.json if file read fails
+ const PACKAGE_JSON = require('./package.json');
+ return PACKAGE_JSON.version;
+ }
+})();
// Create Express app
const app = express();
@@ -1269,10 +1281,25 @@ app.get('/api/system/status', authenticateJWT, async (req, res) => {
transmissionStatus = 'Disconnected';
}
+ // Read version directly from package.json to ensure it's always current
+ let currentVersion = APP_VERSION;
+ try {
+ const packageJsonPath = path.join(__dirname, 'package.json');
+ const packageJsonContent = await fsPromises.readFile(packageJsonPath, 'utf8');
+ const packageData = JSON.parse(packageJsonContent);
+ currentVersion = packageData.version;
+
+ // Log the version for debugging
+ console.log(`System status endpoint returning version: ${currentVersion}`);
+ } catch (err) {
+ console.error('Error reading package.json in status endpoint:', err);
+ // Fall back to the cached APP_VERSION
+ }
+
res.json({
status: 'success',
data: {
- version: APP_VERSION,
+ version: currentVersion,
uptime,
transmissionStatus
}