Skip to content

Commit 430aeee

Browse files
authored
Merge pull request #26 from MrAlders0n/copilot/fix-auto-ping-status-behavior
Fix auto ping status sequence to prevent countdown timer conflicts
2 parents ea81104 + 4a17552 commit 430aeee

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

content/wardrive.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,12 @@ async function sendPing(manual = false) {
471471
return;
472472
}
473473

474+
// Stop the countdown timer when sending an auto ping to avoid status conflicts
475+
if (!manual && state.running) {
476+
stopAutoCountdown();
477+
setStatus("Sending auto ping...", "text-sky-300");
478+
}
479+
474480
let lat, lon, accuracy;
475481

476482
// In auto mode, always use the most recent GPS coordinates from the watch
@@ -519,20 +525,21 @@ async function sendPing(manual = false) {
519525
// Start cooldown period after successful ping
520526
startCooldown();
521527

528+
// Update status after ping is sent
529+
// Brief delay to show "Ping sent" status before moving to "Waiting for API post"
522530
setStatus(manual ? "Ping sent" : "Auto ping sent", "text-emerald-300");
531+
532+
setTimeout(() => {
533+
if (state.connection) {
534+
setStatus("Waiting for API post", "text-sky-300");
535+
}
536+
}, STATUS_UPDATE_DELAY_MS);
523537

524538
// Schedule MeshMapper API call with 7-second delay (non-blocking)
525539
// Clear any existing timer first
526540
if (state.meshMapperTimer) {
527541
clearTimeout(state.meshMapperTimer);
528542
}
529-
530-
// Update status to show we're waiting to post to API
531-
setTimeout(() => {
532-
if (state.connection) {
533-
setStatus("Waiting to post to API", "text-sky-300");
534-
}
535-
}, STATUS_UPDATE_DELAY_MS);
536543

537544
state.meshMapperTimer = setTimeout(async () => {
538545
// Capture accuracy in closure to ensure it's available in nested callback

0 commit comments

Comments
 (0)