Rewrite history.js: loading spinner, active-row highlight, unified state, 300ms debounce, signal guards throughout trip loader

This commit is contained in:
Mathieu Moran
2026-08-11 05:37:15 -04:00
parent 3d6955f20f
commit fa93384a8e
2 changed files with 225 additions and 343 deletions
+18
View File
@@ -1872,6 +1872,24 @@ road test. Each item tracked in [BUGS.md](./BUGS.md).
- BUG-09: Geocode pre-caching for fast scrubber (pre-existing)
- BUG-10: GPS-only false trips gated on OBD presence (pre-existing). Side fix: `refresh_trips()` preserves existing trips when `was_car_ever_connected()` is False (was deleting all trips on restart).
**BUG-07 supplementary fix — history.js rewrite (`static/js/history.js`):**
The trip history page had lingering responsiveness issues (freezing on rapid trip-switching,
no loading feedback, no visual active-trip indicator). A full clean rewrite of the JS was done
rather than incremental patching:
- **Map loading spinner**: Leaflet control in top-right corner, shown during trip fetch + render.
- **Active row highlight**: `.table-active` class on the selected trip row.
- **Debounce**: 300ms (was 100ms) to prevent accidental double-taps from stacking loads.
- **Unified state**: Single `st` object instead of 10+ scattered module-level variables.
- **Unified AbortController**: `st.ctrl` cancels both fetch and downstream rendering in one shot.
- **Geocode preload**: kicks off immediately after fetch, before map rendering, so cache is warm
by the time the scrubber moves.
- **Signal guards**: `sig.aborted` checked after every async step (route build, fitBounds,
timeline init) so rapid switching can't leave stale layers on the map.
- **Play/pause timeline preserved** — kept as-is per user request.
- **Delete/checkbox/batch-delete flow preserved** — no logic changes, just cleaner names.
- **Same JS file works on both Pi and server**: tile URL/attrib/zoom defaults read from
`data-*` attributes on `#history-map`, with Pi-local fallbacks when absent.
**Deployed, awaiting in-car test:**
- BUG-01: Dual-radio setup — wlan0 is permanent AP at 10.42.0.1, wlan1 handles internet uplink only. `yaris_uplink.py` no longer touches the AP. In-car access card on Settings page shows hotspot URL + cell-data warning. Netwatch fixed to not tear down AP when clients connected (backup, not needed with dual-radio).