fix: pr feedback

This commit is contained in:
guarzo
2025-09-17 15:50:26 +00:00
parent 873946a1a6
commit cf1c103a46

View File

@@ -16,6 +16,21 @@ const SystemKillsContent = () => {
} = useMapRootState(); } = useMapRootState();
const [systemId] = selectedSystems || []; const [systemId] = selectedSystems || [];
const whCacheRef = useMemo(() => new Map<number, boolean>(), []);
const isWormholeSystem = useCallback(
(systemId: number): boolean => {
const cached = whCacheRef.get(systemId);
if (cached !== undefined) return cached;
const info = getSystemStaticInfo(systemId);
const isWH = info?.system_class != null ? isWormholeSpace(Number(info.system_class)) : false;
whCacheRef.set(systemId, isWH);
return isWH;
},
[whCacheRef],
);
const { kills, isLoading, error } = useSystemKills({ const { kills, isLoading, error } = useSystemKills({
systemId, systemId,
@@ -30,24 +45,10 @@ const SystemKillsContent = () => {
const filteredKills = useMemo(() => { const filteredKills = useMemo(() => {
if (!settingsKills.whOnly) return kills; if (!settingsKills.whOnly) return kills;
const whBySystem = new Map<number, boolean>(); const wormholeKills = kills.filter(kill => isWormholeSystem(Number(kill.solar_system_id)));
const wormholeKills = kills.filter(kill => {
const id = Number(kill.solar_system_id);
let isWH = whBySystem.get(id);
if (isWH === undefined) {
const info = getSystemStaticInfo(id);
if (!info || info.system_class == null) {
isWH = false;
} else {
isWH = isWormholeSpace(Number(info.system_class));
}
whBySystem.set(id, isWH);
}
return isWH;
});
return wormholeKills; return wormholeKills;
}, [kills, settingsKills.whOnly]); }, [kills, settingsKills.whOnly, isWormholeSystem]);
if (!isSubscriptionActive) { if (!isSubscriptionActive) {
return ( return (