Remove redundant map refresh calls and optimize refresh triggers#161
Conversation
- Removed scheduleCoverageRefresh() calls from postApiInBackground() - Removed scheduleCoverageRefresh() calls from postApiAndRefreshMap() - Removed scheduleCoverageRefresh() call from primeGpsOnce() - Map Refresh Service is now the only mechanism for map updates - Service handles refreshes via 5s timer and 25m movement triggers Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
|
@copilot Will the map still be refresh on GPS fix. I liked the on connect immedaitly update GPS to map |
Yes, the map still refreshes immediately on GPS fix during connection. The sequence is:
The map will update just as quickly as before. The difference is the refresh now happens via the Map Refresh Service's initial refresh (line 934 in The Map Refresh Service continues to refresh the map every 5 seconds and when you move 25 meters, so the map stays current throughout your wardrive session. |
- Removed 5-second timer-based map refresh - Map now refreshes on 25m movement or successful API flush - Updated trigger types: 'initial' | 'gps' | 'api_flush' - Simplified Map Refresh Service (no timer management needed) - Map updates only when data is actually posted to API Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR optimizes the map refresh system by eliminating redundant refresh calls and replacing inefficient timer-based polling with event-driven triggers. The changes remove duplicate map refreshes that occurred during the TX ping lifecycle and replace a 5-second polling timer with targeted refresh triggers based on actual data updates (25m GPS movement and API flush completion).
Key Changes
- Removed redundant
scheduleCoverageRefresh()calls from TX ping flow (postApiInBackground,postApiAndRefreshMap,primeGpsOnce) - Eliminated 5-second timer-based map refresh in favor of GPS movement (25m) and API flush triggers
- Improved UI responsiveness by removing unnecessary
setTimeoutdelays when unlocking ping controls
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
After PR #160 implemented the Map Refresh Service as an always-on background service (5s timer + 25m movement triggers), redundant
scheduleCoverageRefresh()calls remained in the TX ping flow, causing duplicate map refreshes. Additionally, the 5-second timer-based refresh was inefficient and not aligned with actual data updates.Changes
Phase 1: Remove Redundant Map Refresh Calls
Removed redundant map refresh calls from:
postApiInBackground()- Eliminated setTimeout wrapper with conditional refresh after API postpostApiAndRefreshMap()- Eliminated setTimeout wrapper with conditional refresh after message queueingprimeGpsOnce()- Eliminated conditional refresh after initial GPS acquisitionBefore:
After:
Phase 2: Optimize Map Refresh Triggers
Changed map refresh triggers from:
To:
Implementation:
MAP_REFRESH_INTERVAL_MSconstant and timer managementcheckAndRefreshMap('api_flush')trigger after successful API batch post'initial' | 'gps' | 'api_flush'setIntervaltimer needed)Benefits
Net: -35 lines total (66 deletions, 31 insertions)
Original prompt
This pull request was created from Copilot chat.
💡 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.