Fix: skip session delta entries with no tank definition or average

The /session/ page crashed when a tracked player's tank stats included
a tank with no matching tank definition or no average stats (WN8
baseline). The delta memo dereferenced `tank.id` on a possibly missing
definition and forced `average?.mu!` through as non-null, so a missing
average threw inside `compositeStats`/`calculateWN8` uncaught, breaking
the page on every load while the bad state persisted in localStorage.

Skip those entries instead of crashing: entries with no tank
definition or no average `mu` are dropped from the delta via
`flatMap`, so the rest of the session table still renders.
This commit is contained in:
Mark Greene committed 2026-09-23 08:21:16 +12:00
1 parent 84f950ade4
commit 88643d366d
1 file changed
+7 -3
@@ -90,15 +90,19 @@ function Content() {
session.tracking && tankStatsB
? deltaTankStats(session.player.stats, tankStatsB)
.sort((a, b) => b.last_battle_time - a.last_battle_time)
.map((entry) => {
.flatMap((entry) => {
const tank = tankDefinitions.tanks[entry.tank_id];
if (!tank) return [];
const average = averageDefinitions.averages[tank.id];
if (!average?.mu) return [];
const composite = compositeStats(
{ ...entry.all, battle_life_time: entry.battle_life_time },
average?.mu!,
average.mu,
);
return { tank, composite };
return [{ tank, composite }];
})
: undefined,
[session.tracking && session.player, tankStatsB],