fix: kill count subscript position on firefox, and remove kill filter for single system (#148)

This commit is contained in:
guarzo
2025-02-05 07:59:30 -07:00
committed by GitHub
parent a850071965
commit 860d20dc66
3 changed files with 21 additions and 18 deletions

View File

@@ -39,7 +39,7 @@ export const SystemKills: React.FC = () => {
const showLoading = isLoading && kills.length === 0; const showLoading = isLoading && kills.length === 0;
const filteredKills = useMemo(() => { const filteredKills = useMemo(() => {
if (!settings.whOnly) return kills; if (!settings.whOnly || !visible) return kills;
return kills.filter(kill => { return kills.filter(kill => {
const system = systems.find(sys => sys.system_static_info.solar_system_id === kill.solar_system_id); const system = systems.find(sys => sys.system_static_info.solar_system_id === kill.solar_system_id);
if (!system) { if (!system) {

View File

@@ -117,7 +117,6 @@ export const CompactKillRow: React.FC<CompactKillRowProps> = ({
'text-xs whitespace-nowrap overflow-hidden leading-none' 'text-xs whitespace-nowrap overflow-hidden leading-none'
)} )}
> >
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
{victimShipUrl && ( {victimShipUrl && (
<div className="relative shrink-0 w-8 h-8 overflow-hidden"> <div className="relative shrink-0 w-8 h-8 overflow-hidden">
@@ -147,7 +146,7 @@ export const CompactKillRow: React.FC<CompactKillRowProps> = ({
href={zkillLink('kill', killmail_id)} href={zkillLink('kill', killmail_id)}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
className="relative shrink-0 w-8 h-8 overflow-hidden" className="relative block shrink-0 w-8 h-8 overflow-hidden"
> >
<img <img
src={victimPrimaryLogoUrl} src={victimPrimaryLogoUrl}
@@ -206,7 +205,7 @@ export const CompactKillRow: React.FC<CompactKillRowProps> = ({
href={zkillLink('kill', killmail_id)} href={zkillLink('kill', killmail_id)}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
className="relative shrink-0 w-8 h-8 overflow-hidden" className="relative block shrink-0 w-8 h-8 overflow-hidden"
> >
<img <img
src={attackerPrimaryImageUrl} src={attackerPrimaryImageUrl}
@@ -223,7 +222,6 @@ export const CompactKillRow: React.FC<CompactKillRowProps> = ({
attackerSubscript.cssClass, attackerSubscript.cssClass,
'text-[0.6rem] leading-none px-[2px]' 'text-[0.6rem] leading-none px-[2px]'
)} )}
style={{ bottom: 0, right: 0 }}
> >
{attackerSubscript.label} {attackerSubscript.label}
</span> </span>

View File

@@ -38,9 +38,14 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s
const [settings] = useKillsWidgetSettings(); const [settings] = useKillsWidgetSettings();
const excludedSystems = settings.excludedSystems; const excludedSystems = settings.excludedSystems;
const visibleSystemIds = useMemo(() => { // 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).filter(id => !excludedSystems.includes(Number(id)));
}, [systems, excludedSystems]); }
return systems.map(s => s.id);
}, [systems, excludedSystems, showAllVisible]);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
@@ -80,7 +85,7 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s
if (showAllVisible || forceFallback) { if (showAllVisible || forceFallback) {
eventType = OutCommand.getSystemsKills; eventType = OutCommand.getSystemsKills;
requestData = { requestData = {
system_ids: visibleSystemIds, system_ids: effectiveSystemIds,
since_hours: sinceHours, since_hours: sinceHours,
}; };
} else if (systemId) { } else if (systemId) {
@@ -106,7 +111,7 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s
const sid = systemId ?? 'unknown'; const sid = systemId ?? 'unknown';
mergeKillsIntoGlobal({ [sid]: arr }); mergeKillsIntoGlobal({ [sid]: arr });
} }
// multiple => `resp.systems_kills` // multiple systems => `resp.systems_kills`
else if (resp?.systems_kills) { else if (resp?.systems_kills) {
mergeKillsIntoGlobal(resp.systems_kills as Record<string, DetailedKill[]>); mergeKillsIntoGlobal(resp.systems_kills as Record<string, DetailedKill[]>);
} else { } else {
@@ -119,7 +124,7 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s
setIsLoading(false); setIsLoading(false);
} }
}, },
[showAllVisible, systemId, outCommand, visibleSystemIds, sinceHours, mergeKillsIntoGlobal], [showAllVisible, systemId, outCommand, effectiveSystemIds, sinceHours, mergeKillsIntoGlobal],
); );
const debouncedFetchKills = useMemo( const debouncedFetchKills = useMemo(
@@ -133,15 +138,15 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s
const finalKills = useMemo(() => { const finalKills = useMemo(() => {
if (showAllVisible) { if (showAllVisible) {
return visibleSystemIds.flatMap(sid => detailedKills[sid] ?? []); return effectiveSystemIds.flatMap(sid => detailedKills[sid] ?? []);
} else if (systemId) { } else if (systemId) {
return detailedKills[systemId] ?? []; return detailedKills[systemId] ?? [];
} else if (didFallbackFetch.current) { } else if (didFallbackFetch.current) {
// if we already did a fallback, we may have data for multiple systems // 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 []; return [];
}, [showAllVisible, systemId, didFallbackFetch, visibleSystemIds, detailedKills]); }, [showAllVisible, systemId, effectiveSystemIds, detailedKills]);
const effectiveIsLoading = isLoading && finalKills.length === 0; const effectiveIsLoading = isLoading && finalKills.length === 0;
@@ -150,19 +155,19 @@ export function useSystemKills({ systemId, outCommand, showAllVisible = false, s
didFallbackFetch.current = true; didFallbackFetch.current = true;
// Cancel any queued debounced calls, then do the fallback. // Cancel any queued debounced calls, then do the fallback.
debouncedFetchKills.cancel(); 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(() => { useEffect(() => {
if (visibleSystemIds.length === 0) return; if (effectiveSystemIds.length === 0) return;
if (showAllVisible || systemId) { if (showAllVisible || systemId) {
debouncedFetchKills(); debouncedFetchKills();
// Clean up the debounce on unmount or changes // Clean up the debounce on unmount or changes
return () => debouncedFetchKills.cancel(); return () => debouncedFetchKills.cancel();
} }
}, [showAllVisible, systemId, visibleSystemIds, debouncedFetchKills]); }, [showAllVisible, systemId, effectiveSystemIds, debouncedFetchKills]);
const refetch = useCallback(() => { const refetch = useCallback(() => {
debouncedFetchKills.cancel(); debouncedFetchKills.cancel();