fix(ui): refresh LOCAL SYSTEM after a jump instead of waiting for a page reload (#30)
CI / build + unit + e2e (pull_request) Successful in 2m39s

WorldMapPanel owns the world state and applied the /api/jump response
locally, so MissionControl's lifted /api/system state (LOCAL SYSTEM tab,
CARGO HOLD, SECTOR row) stayed on the previous system until a full refresh.
The panel now takes an onJumped callback that MissionControl wires to an
/api/system refetch after every successful jump.
This commit is contained in:
2026-09-29 10:00:18 +00:00
parent e6c88b10c2
commit e27ff7015e
5 changed files with 48 additions and 5 deletions
+4 -2
View File
@@ -11,9 +11,10 @@ import type { WorldState } from '@/lib/game/save'
interface WorldMapPanelProps {
height?: number
onJumped?: () => void // #30 — let the parent refresh /api/system after a successful jump
}
export function WorldMapPanel({ height = 380 }: WorldMapPanelProps) {
export function WorldMapPanel({ height = 380, onJumped }: WorldMapPanelProps) {
const [world, setWorld] = useState<WorldState | null>(null)
const [error, setError] = useState<string | null>(null)
const [jumpingId, setJumpingId] = useState<number | null>(null)
@@ -47,12 +48,13 @@ export function WorldMapPanel({ height = 380 }: WorldMapPanelProps) {
const body = (await res.json()) as WorldState & { error?: string }
if (!res.ok) throw new Error(body.error ?? `HTTP ${res.status}`)
setWorld(body) // fresh state straight from the response — no refetch needed
onJumped?.() // #30 — parent re-fetches /api/system (LOCAL SYSTEM + CARGO HOLD mirror it)
} catch (err: unknown) {
setError(err instanceof Error ? err.message : String(err))
} finally {
setJumpingId(null)
}
}, [])
}, [onJumped])
if (error && !world) {
return (