Fix mode switch re-entry regressions

This commit is contained in:
James Smith
2026-03-18 21:26:01 +00:00
parent 98bb6ce10b
commit 86625cf3ec
4 changed files with 42 additions and 23 deletions

View File

@@ -16,8 +16,9 @@ const Meshtastic = (function() {
// Map state
let meshMap = null;
let meshMarkers = {}; // nodeId -> marker
let localNodeId = null;
let meshMarkers = {}; // nodeId -> marker
let localNodeId = null;
let clickDelegationAttached = false;
/**
* Initialize the Meshtastic mode
@@ -32,11 +33,14 @@ const Meshtastic = (function() {
/**
* Setup event delegation for dynamically created elements
*/
function setupEventDelegation() {
// Handle button clicks in Leaflet popups and elsewhere
document.addEventListener('click', function(e) {
const tracerouteBtn = e.target.closest('.mesh-traceroute-btn');
if (tracerouteBtn) {
function setupEventDelegation() {
if (clickDelegationAttached) return;
clickDelegationAttached = true;
// Handle button clicks in Leaflet popups and elsewhere
document.addEventListener('click', function(e) {
const tracerouteBtn = e.target.closest('.mesh-traceroute-btn');
if (tracerouteBtn) {
const nodeId = tracerouteBtn.dataset.nodeId;
if (nodeId) {
sendTraceroute(nodeId);

View File

@@ -14,10 +14,11 @@ const SSTV = (function() {
let issMarker = null;
let issTrackLine = null;
let issPosition = null;
let issUpdateInterval = null;
let countdownInterval = null;
let nextPassData = null;
let pendingMapInvalidate = false;
let issUpdateInterval = null;
let countdownInterval = null;
let nextPassData = null;
let pendingMapInvalidate = false;
let locationListenersAttached = false;
// ISS frequency
const ISS_FREQ = 145.800;
@@ -92,10 +93,12 @@ const SSTV = (function() {
if (latInput && storedLat) latInput.value = storedLat;
if (lonInput && storedLon) lonInput.value = storedLon;
// Add change handlers to save and refresh
if (latInput) latInput.addEventListener('change', saveLocationFromInputs);
if (lonInput) lonInput.addEventListener('change', saveLocationFromInputs);
}
if (!locationListenersAttached) {
if (latInput) latInput.addEventListener('change', saveLocationFromInputs);
if (lonInput) lonInput.addEventListener('change', saveLocationFromInputs);
locationListenersAttached = true;
}
}
/**
* Save location from input fields

View File

@@ -27,11 +27,24 @@ const WeatherSat = (function() {
let consoleAutoHideTimer = null;
let currentModalFilename = null;
let locationListenersAttached = false;
let initialized = false;
/**
* Initialize the Weather Satellite mode
*/
function init() {
if (initialized) {
checkStatus();
loadImages();
loadLocationInputs();
loadPasses();
startCountdownTimer();
checkSchedulerStatus();
initGroundMap();
return;
}
initialized = true;
checkStatus();
loadImages();
loadLocationInputs();
@@ -39,14 +52,6 @@ const WeatherSat = (function() {
startCountdownTimer();
checkSchedulerStatus();
initGroundMap();
// Re-filter passes when satellite selection changes
const satSelect = document.getElementById('weatherSatSelect');
if (satSelect) {
satSelect.addEventListener('change', () => {
applyPassFilter();
});
}
}
/**