Changesets · Branches · Tags · Compare
| Changeset | a1d3189fba30c78e9dca3f29e0a5df029f35021e32d49e114eea9db4a34f2cee |
|---|---|
| Author | Gemini CLI <gemini@example.com> · 2026-05-23 21:52 -04:00 |
| Committer | Gemini CLI <gemini@example.com> · 2026-05-23 21:52 -04:00 |
| Parents | c867dff8b92f |
1 file changed
modified src/app/page.tsx +4 −3
| @@ -244,6 +244,7 @@ | ||
| 244 | 244 | |
| 245 | 245 | // ── SHARED FETCH UTILITY (Fixes #107 — single definition, not 3 copies) ── |
| 246 | 246 | const fetchEndpoint = useCallback(async (url: string, transform?: (d: any) => any, options?: RequestInit) => { |
| 247 | + if (typeof document !== 'undefined' && document.hidden) return; | |
| 247 | 248 | try { |
| 248 | 249 | const res = await fetch(url, options); |
| 249 | 250 | if (res.ok) { |
| @@ -359,13 +360,13 @@ | ||
| 359 | 360 | } |
| 360 | 361 | |
| 361 | 362 | if (activeLayers.balloons) { |
| 362 | - intervals.push(setInterval(() => fetchEndpoint('/api/balloons', d => ({ balloons: d.balloons })), 30000)); // 30s | |
| 363 | + intervals.push(setInterval(() => fetchEndpoint('/api/balloons', d => ({ balloons: d.balloons })), 300000)); // 5m | |
| 363 | 364 | } |
| 364 | 365 | if (activeLayers.radiation) { |
| 365 | - intervals.push(setInterval(() => fetchEndpoint('/api/radiation', d => ({ radiation: d.stations })), 60000)); // 1m | |
| 366 | + intervals.push(setInterval(() => fetchEndpoint('/api/radiation', d => ({ radiation: d.stations })), 300000)); // 5m | |
| 366 | 367 | } |
| 367 | 368 | if (activeLayers.maritime) { |
| 368 | - intervals.push(setInterval(() => fetchEndpoint('/api/maritime', d => ({ maritime_ports: d.ports, maritime_chokepoints: d.chokepoints, maritime_ships: d.ships })), 10000)); // 10s | |
| 369 | + intervals.push(setInterval(() => fetchEndpoint('/api/maritime', d => ({ maritime_ports: d.ports, maritime_chokepoints: d.chokepoints, maritime_ships: d.ships })), 60000)); // 1m | |
| 369 | 370 | } |
| 370 | 371 | // Fires: no polling needed (data changes very slowly, initial fetch is enough) |
| 371 | 372 | return () => intervals.forEach(clearInterval); |