mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 06:40:00 -07:00
fix: stop satellite position polling when mode is inactive
Use postMessage from parent page to notify the satellite dashboard iframe of visibility changes, preventing unnecessary POST requests to /satellite/position when the user isn't viewing satellite mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4364,6 +4364,10 @@
|
||||
if (wifiLayoutContainer) wifiLayoutContainer.style.display = mode === 'wifi' ? 'flex' : 'none';
|
||||
if (btLayoutContainer) btLayoutContainer.style.display = mode === 'bluetooth' ? 'flex' : 'none';
|
||||
if (satelliteVisuals) satelliteVisuals.style.display = mode === 'satellite' ? 'block' : 'none';
|
||||
const satFrame = document.getElementById('satelliteDashboardFrame');
|
||||
if (satFrame && satFrame.contentWindow) {
|
||||
satFrame.contentWindow.postMessage({type: 'satellite-visibility', visible: mode === 'satellite'}, '*');
|
||||
}
|
||||
if (aprsVisuals) aprsVisuals.style.display = mode === 'aprs' ? 'flex' : 'none';
|
||||
if (tscmVisuals) tscmVisuals.style.display = mode === 'tscm' ? 'flex' : 'none';
|
||||
if (spyStationsVisuals) spyStationsVisuals.style.display = mode === 'spystations' ? 'flex' : 'none';
|
||||
|
||||
@@ -362,6 +362,33 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
let positionPollingInterval = null;
|
||||
|
||||
function startPositionPolling() {
|
||||
if (!positionPollingInterval) {
|
||||
updateRealTimePositions();
|
||||
positionPollingInterval = setInterval(updateRealTimePositions, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
function stopPositionPolling() {
|
||||
if (positionPollingInterval) {
|
||||
clearInterval(positionPollingInterval);
|
||||
positionPollingInterval = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Listen for visibility messages from parent page (embedded mode)
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.data && event.data.type === 'satellite-visibility') {
|
||||
if (event.data.visible) {
|
||||
startPositionPolling();
|
||||
} else {
|
||||
stopPositionPolling();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
loadDashboardSatellites();
|
||||
setupEmbeddedMode();
|
||||
@@ -370,7 +397,11 @@
|
||||
updateClock();
|
||||
setInterval(updateClock, 1000);
|
||||
setInterval(updateCountdown, 1000);
|
||||
setInterval(updateRealTimePositions, 5000);
|
||||
// In standalone mode, start polling immediately.
|
||||
// In embedded mode, wait for parent to signal visibility.
|
||||
if (!isEmbedded) {
|
||||
startPositionPolling();
|
||||
}
|
||||
loadAgents();
|
||||
if (!usedShared) {
|
||||
getLocation();
|
||||
|
||||
Reference in New Issue
Block a user