Commit cbf6d4b
committed
station-detail: prefetch on map hover + spinner overlay on chart
Two-part fix for the slow + jittery station-switch experience on
`/s/<slug>` when the user clicks between stations on the map.
**Prefetch on hover** (`StationMap.tsx`, `query/stations.ts`):
- New `onMarkerHover?: (id) => void` prop on `StationMap`; fires
80 ms after the cursor settles on a circle (debounced via
`setTimeout` + `mouseout` cancel). Quick mouse-passes don't
trigger requests.
- `prefetchStationDetail(qc, slug, fromS, toS, binS)` in the query
module chains the `/info` → `/totals` calls the next page will
issue. Uses the SAME query keys (`station-info`/`station-avail`)
as the live hooks, so the eventual `useStationAvailability` mount
hits the warm cache instead of refetching.
- `StationDetail.tsx` wires the hook by passing
`onMarkerHover={(id) => prefetchStationDetail(qc, id, bufFromS,
bufToS, binS)}` to its `StationMap`.
**Spinner overlay** (`StationDetail.tsx`):
- Wraps `StationAvailabilityChart` in a relative container. While
`rangeQuery.isFetching` is true, the chart dims to 40% opacity
and an absolute-positioned `<CircularProgress />` floats over it.
Pre-existing initial-load spinner (no data yet) is unchanged.
**Drops cross-station `keepPreviousData`** (`query/stations.ts`):
- `useStationAvailability`'s `placeholderData` is now selective:
keeps prev rows only when `gbfsId` is unchanged (same station,
new range/bin). On cross-station nav, drops to undefined so the
chart shows the spinner instead of the previous station's data
with the new station's y-range — the "loaded but wrong" effect
the user reported.
Verified live via synthetic `mouseover` on a hit-circle: 80 ms later
the `/info` + chained `/totals` requests fire with the hovered
station's id, before any click.
BE perf (uncached `/api/totals?kind=availability` at 2.0–2.8 s) is
a separate investigation — see task #64.1 parent 0745438 commit cbf6d4b
3 files changed
Lines changed: 159 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
96 | 117 | | |
97 | 118 | | |
98 | 119 | | |
| |||
212 | 233 | | |
213 | 234 | | |
214 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
215 | 247 | | |
216 | 248 | | |
217 | 249 | | |
| |||
220 | 252 | | |
221 | 253 | | |
222 | 254 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
| 255 | + | |
227 | 256 | | |
228 | 257 | | |
229 | 258 | | |
| |||
240 | 269 | | |
241 | 270 | | |
242 | 271 | | |
243 | | - | |
| 272 | + | |
244 | 273 | | |
245 | 274 | | |
246 | 275 | | |
| |||
320 | 349 | | |
321 | 350 | | |
322 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
323 | 356 | | |
324 | 357 | | |
325 | 358 | | |
| |||
352 | 385 | | |
353 | 386 | | |
354 | 387 | | |
| 388 | + | |
355 | 389 | | |
356 | 390 | | |
357 | 391 | | |
| |||
399 | 433 | | |
400 | 434 | | |
401 | 435 | | |
| 436 | + | |
402 | 437 | | |
403 | 438 | | |
404 | 439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
197 | 198 | | |
198 | 199 | | |
199 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
200 | 213 | | |
201 | 214 | | |
202 | 215 | | |
| |||
478 | 491 | | |
479 | 492 | | |
480 | 493 | | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
498 | 524 | | |
499 | 525 | | |
500 | 526 | | |
| |||
522 | 548 | | |
523 | 549 | | |
524 | 550 | | |
| 551 | + | |
525 | 552 | | |
526 | 553 | | |
527 | 554 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
57 | 64 | | |
58 | 65 | | |
59 | | - | |
| 66 | + | |
60 | 67 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 68 | + | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
| |||
178 | 181 | | |
179 | 182 | | |
180 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
181 | 213 | | |
182 | 214 | | |
183 | 215 | | |
| |||
191 | 223 | | |
192 | 224 | | |
193 | 225 | | |
194 | | - | |
| 226 | + | |
195 | 227 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
218 | 238 | | |
219 | | - | |
220 | 239 | | |
221 | 240 | | |
222 | 241 | | |
223 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
224 | 265 | | |
225 | 266 | | |
226 | 267 | | |
| |||
0 commit comments