From 6a6e0ae4912099eb91c590fff69e1547da0381b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Dec 2025 00:00:48 +0000 Subject: [PATCH 1/2] Initial plan From 9ecf42b12e84a45fa684fbefae527650e33659e4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Dec 2025 00:03:39 +0000 Subject: [PATCH 2/2] Add countdown timer for API post delay - Changed "Waiting for API post" to "Wait to post API" - Added countdown display from 7s to 0s during API post delay - Implemented startApiCountdown, stopApiCountdown, and updateApiCountdownStatus functions - Added state variables apiCountdownTimer and apiPostTime - Countdown updates every second similar to auto-ping countdown - Clean up API countdown timer on disconnect Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com> --- content/wardrive.js | 50 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/content/wardrive.js b/content/wardrive.js index 81e5dec..5735252 100644 --- a/content/wardrive.js +++ b/content/wardrive.js @@ -62,7 +62,9 @@ const state = { cooldownEndTime: null, // Timestamp when cooldown period ends cooldownUpdateTimer: null, // Timer to re-enable controls after cooldown autoCountdownTimer: null, // Timer for auto-ping countdown display - nextAutoPingTime: null // Timestamp when next auto-ping will occur + nextAutoPingTime: null, // Timestamp when next auto-ping will occur + apiCountdownTimer: null, // Timer for API post countdown display + apiPostTime: null // Timestamp when API post will occur }; // ---- UI helpers ---- @@ -106,6 +108,42 @@ function stopAutoCountdown() { } state.nextAutoPingTime = null; } +function updateApiCountdownStatus() { + if (!state.apiPostTime) { + return; + } + + const remainingMs = state.apiPostTime - Date.now(); + if (remainingMs <= 0) { + setStatus("Posting to API...", "text-sky-300"); + return; + } + + const remainingSec = Math.ceil(remainingMs / 1000); + setStatus(`Wait to post API (${remainingSec}s)`, "text-sky-300"); +} +function startApiCountdown(delayMs) { + // Stop any existing countdown + stopApiCountdown(); + + // Set the API post time + state.apiPostTime = Date.now() + delayMs; + + // Update immediately + updateApiCountdownStatus(); + + // Update every second + state.apiCountdownTimer = setInterval(() => { + updateApiCountdownStatus(); + }, 1000); +} +function stopApiCountdown() { + if (state.apiCountdownTimer) { + clearInterval(state.apiCountdownTimer); + state.apiCountdownTimer = null; + } + state.apiPostTime = null; +} function isInCooldown() { return state.cooldownEndTime && Date.now() < state.cooldownEndTime; } @@ -526,12 +564,13 @@ async function sendPing(manual = false) { startCooldown(); // Update status after ping is sent - // Brief delay to show "Ping sent" status before moving to "Waiting for API post" + // Brief delay to show "Ping sent" status before moving to countdown setStatus(manual ? "Ping sent" : "Auto ping sent", "text-emerald-300"); setTimeout(() => { if (state.connection) { - setStatus("Waiting for API post", "text-sky-300"); + // Start countdown for API post + startApiCountdown(MESHMAPPER_DELAY_MS); } }, STATUS_UPDATE_DELAY_MS); @@ -545,6 +584,10 @@ async function sendPing(manual = false) { // Capture accuracy in closure to ensure it's available in nested callback const capturedAccuracy = accuracy; + // Stop the API countdown since we're posting now + stopApiCountdown(); + setStatus("Posting to API...", "text-sky-300"); + try { await postToMeshMapperAPI(lat, lon); } catch (error) { @@ -718,6 +761,7 @@ async function connect() { state.cooldownUpdateTimer = null; } stopAutoCountdown(); + stopApiCountdown(); state.cooldownEndTime = null; state.lastFix = null;