Skip to content

Update map refresh timing and status messages to follow API post lifecycle#20

Merged
MrAlders0n merged 4 commits into
mainfrom
copilot/update-map-logic-and-descriptions
Dec 17, 2025
Merged

Update map refresh timing and status messages to follow API post lifecycle#20
MrAlders0n merged 4 commits into
mainfrom
copilot/update-map-logic-and-descriptions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 17, 2025

Map iframe was refreshing 5s after ping, before API post completed. Status messages were generic. Now map refreshes after API post with proper lifecycle status updates.

Changes

Map refresh timing

  • Moved refresh from sendPing() to execute 1s after MeshMapper API post completes (total ~8s vs previous 5s)
  • Ensures backend processes data before map reload
  • Modified scheduleCoverageRefresh() to accept delayMs parameter (default 0)

Status message flow

  • "Ping sent" → "Waiting to post to API" (100ms delay) → "Idle" (after API + map refresh)
  • Added constants: STATUS_UPDATE_DELAY_MS, MAP_REFRESH_DELAY_MS

Error handling

  • Wrapped API call in try/catch to prevent status from getting stuck on API failures
  • Captured accuracy in closure to avoid undefined reference in nested callbacks
state.meshMapperTimer = setTimeout(async () => {
  const capturedAccuracy = accuracy;
  try {
    await postToMeshMapperAPI(lat, lon);
  } catch (error) {
    console.error("MeshMapper API post failed:", error);
  }
  
  setTimeout(() => {
    if (capturedAccuracy && capturedAccuracy < GPS_ACCURACY_THRESHOLD_M) {
      scheduleCoverageRefresh(lat, lon);
    }
    if (state.connection) setStatus("Idle", "text-slate-300");
  }, MAP_REFRESH_DELAY_MS);
}, MESHMAPPER_DELAY_MS);
Original prompt

Right now the iframe is updated a certain amount of time after the ping. I want to change that logic.

I want the map to update after the cooldown instead with the GPS coords that were posted to the API.

I also want the Status: Ping sent to be more decsriptive. When the ping goes out say Ping sent

When in cooldown and waiting to post to api. say "waiting to post to api"

When done posting to API say "idle" until the next ping


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 17, 2025 21:08
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
@MrAlders0n MrAlders0n marked this pull request as ready for review December 17, 2025 21:13
@MrAlders0n MrAlders0n merged commit 435a2de into main Dec 17, 2025
Copilot AI changed the title [WIP] Update iframe logic for map updates and status messages Update map refresh timing and status messages to follow API post lifecycle Dec 17, 2025
Copilot AI requested a review from MrAlders0n December 17, 2025 21:13
@MrAlders0n MrAlders0n deleted the copilot/update-map-logic-and-descriptions branch December 18, 2025 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants