From 860d20dc668f25bbd50047a9b30c225d25d3b271 Mon Sep 17 00:00:00 2001 From: guarzo Date: Wed, 5 Feb 2025 07:59:30 -0700 Subject: [PATCH] fix: kill count subscript position on firefox, and remove kill filter for single system (#148) --- .../widgets/SystemKills/SystemKills.tsx | 2 +- .../SystemKills/components/CompactKillRow.tsx | 6 ++-- .../SystemKills/hooks/useSystemKills.ts | 31 +++++++++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/SystemKills.tsx b/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/SystemKills.tsx index 6543d54b..667b9da1 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/SystemKills.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/SystemKills.tsx @@ -39,7 +39,7 @@ export const SystemKills: React.FC = () => { const showLoading = isLoading && kills.length === 0; const filteredKills = useMemo(() => { - if (!settings.whOnly) return kills; + if (!settings.whOnly || !visible) return kills; return kills.filter(kill => { const system = systems.find(sys => sys.system_static_info.solar_system_id === kill.solar_system_id); if (!system) { diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/components/CompactKillRow.tsx b/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/components/CompactKillRow.tsx index 0b382f7a..d6e75554 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/components/CompactKillRow.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/components/CompactKillRow.tsx @@ -117,7 +117,6 @@ export const CompactKillRow: React.FC = ({ 'text-xs whitespace-nowrap overflow-hidden leading-none' )} > -
{victimShipUrl && (
@@ -147,7 +146,7 @@ export const CompactKillRow: React.FC = ({ href={zkillLink('kill', killmail_id)} target="_blank" rel="noopener noreferrer" - className="relative shrink-0 w-8 h-8 overflow-hidden" + className="relative block shrink-0 w-8 h-8 overflow-hidden" > = ({ href={zkillLink('kill', killmail_id)} target="_blank" rel="noopener noreferrer" - className="relative shrink-0 w-8 h-8 overflow-hidden" + className="relative block shrink-0 w-8 h-8 overflow-hidden" > = ({ attackerSubscript.cssClass, 'text-[0.6rem] leading-none px-[2px]' )} - style={{ bottom: 0, right: 0 }} > {attackerSubscript.label} diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/hooks/useSystemKills.ts b/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/hooks/useSystemKills.ts index 1456bb8f..42c488e3 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/hooks/useSystemKills.ts +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemKills/hooks/useSystemKills.ts @@ -38,9 +38,14 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s const [settings] = useKillsWidgetSettings(); const excludedSystems = settings.excludedSystems; - const visibleSystemIds = useMemo(() => { - return systems.map(s => s.id).filter(id => !excludedSystems.includes(Number(id))); - }, [systems, excludedSystems]); + // When showing all visible kills, filter out excluded systems; + // when showAllVisible is false, ignore the exclusion filter. + const effectiveSystemIds = useMemo(() => { + if (showAllVisible) { + return systems.map(s => s.id).filter(id => !excludedSystems.includes(Number(id))); + } + return systems.map(s => s.id); + }, [systems, excludedSystems, showAllVisible]); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); @@ -80,7 +85,7 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s if (showAllVisible || forceFallback) { eventType = OutCommand.getSystemsKills; requestData = { - system_ids: visibleSystemIds, + system_ids: effectiveSystemIds, since_hours: sinceHours, }; } else if (systemId) { @@ -106,7 +111,7 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s const sid = systemId ?? 'unknown'; mergeKillsIntoGlobal({ [sid]: arr }); } - // multiple => `resp.systems_kills` + // multiple systems => `resp.systems_kills` else if (resp?.systems_kills) { mergeKillsIntoGlobal(resp.systems_kills as Record); } else { @@ -119,7 +124,7 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s setIsLoading(false); } }, - [showAllVisible, systemId, outCommand, visibleSystemIds, sinceHours, mergeKillsIntoGlobal], + [showAllVisible, systemId, outCommand, effectiveSystemIds, sinceHours, mergeKillsIntoGlobal], ); const debouncedFetchKills = useMemo( @@ -133,15 +138,15 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s const finalKills = useMemo(() => { if (showAllVisible) { - return visibleSystemIds.flatMap(sid => detailedKills[sid] ?? []); + return effectiveSystemIds.flatMap(sid => detailedKills[sid] ?? []); } else if (systemId) { return detailedKills[systemId] ?? []; } else if (didFallbackFetch.current) { // if we already did a fallback, we may have data for multiple systems - return visibleSystemIds.flatMap(sid => detailedKills[sid] ?? []); + return effectiveSystemIds.flatMap(sid => detailedKills[sid] ?? []); } return []; - }, [showAllVisible, systemId, didFallbackFetch, visibleSystemIds, detailedKills]); + }, [showAllVisible, systemId, effectiveSystemIds, detailedKills]); const effectiveIsLoading = isLoading && finalKills.length === 0; @@ -150,19 +155,19 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s didFallbackFetch.current = true; // Cancel any queued debounced calls, then do the fallback. debouncedFetchKills.cancel(); - fetchKills(true); // forceFallback => fetch as though showAll + fetchKills(true); // forceFallback => fetch as though showAllVisible is true } - }, [systemId, showAllVisible, debouncedFetchKills, fetchKills, didFallbackFetch]); + }, [systemId, showAllVisible, debouncedFetchKills, fetchKills]); useEffect(() => { - if (visibleSystemIds.length === 0) return; + if (effectiveSystemIds.length === 0) return; if (showAllVisible || systemId) { debouncedFetchKills(); // Clean up the debounce on unmount or changes return () => debouncedFetchKills.cancel(); } - }, [showAllVisible, systemId, visibleSystemIds, debouncedFetchKills]); + }, [showAllVisible, systemId, effectiveSystemIds, debouncedFetchKills]); const refetch = useCallback(() => { debouncedFetchKills.cancel();