diff --git a/backend/static/mobile.js b/backend/static/mobile.js index 6575f95..9651181 100644 --- a/backend/static/mobile.js +++ b/backend/static/mobile.js @@ -328,6 +328,11 @@ function populateUnitModal(unit, cardStatusInfo = null) { } function getUnitStatus(unitId, unit = null) { + // Prefer roster table data if it was rendered with the current view + if (window.rosterStatusMap && window.rosterStatusMap[unitId]) { + return window.rosterStatusMap[unitId]; + } + // Try to get status from dashboard snapshot if it exists if (window.lastStatusSnapshot && window.lastStatusSnapshot.units && window.lastStatusSnapshot.units[unitId]) { const unitStatus = window.lastStatusSnapshot.units[unitId]; diff --git a/templates/base.html b/templates/base.html index 9370401..f647a78 100644 --- a/templates/base.html +++ b/templates/base.html @@ -137,8 +137,8 @@ - -
+ +
+ +
@@ -206,6 +213,42 @@ } } + // Hard reload function - clears all caches and reloads + async function hardReload() { + try { + // Clear service worker caches + if ('caches' in window) { + const cacheNames = await caches.keys(); + await Promise.all(cacheNames.map(name => caches.delete(name))); + console.log('Cleared all service worker caches'); + } + + // Unregister service workers + if ('serviceWorker' in navigator) { + const registrations = await navigator.serviceWorker.getRegistrations(); + await Promise.all(registrations.map(reg => reg.unregister())); + console.log('Unregistered all service workers'); + } + + // Clear IndexedDB + if ('indexedDB' in window) { + try { + indexedDB.deleteDatabase('sfm-offline-db'); + console.log('Cleared IndexedDB'); + } catch (e) { + console.log('Could not clear IndexedDB:', e); + } + } + + // Force reload with cache bypass + window.location.reload(true); + } catch (error) { + console.error('Error during hard reload:', error); + // Fallback to regular reload + window.location.reload(true); + } + } + // Load saved theme preference if (localStorage.getItem('theme') === 'light') { document.documentElement.classList.remove('dark'); diff --git a/templates/partials/roster_table.html b/templates/partials/roster_table.html index 3ca638a..9471322 100644 --- a/templates/partials/roster_table.html +++ b/templates/partials/roster_table.html @@ -365,6 +365,17 @@ timestampMobileElement.textContent = new Date().toLocaleTimeString(); } + // Keep a lightweight status map around for the mobile modal + const rosterUnits = {{ units | tojson }}; + window.rosterStatusMap = rosterUnits.reduce((acc, unit) => { + acc[unit.id] = { + status: unit.status || 'Unknown', + age: unit.age || 'N/A', + last: unit.last_seen || 'Never' + }; + return acc; + }, {}); + // Sorting state let currentSort = { column: null, direction: 'asc' };