mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-02 22:12:55 +00:00
* fix(Map): fix design of kills widget, fix design of signatures widget - refactor a lot of code, fixed problem with tooltip blinking * fix(Map): refactor Tracking dialog, refactor Activity tracker, refactor codebase and some styles * fix(Core): don't count character passage on manual add connection * refactor(Core): improved characters tracking API * fix(Core): fixed link signature to system on 'leads to' set * fix(Map): Refactor map settings and prepared it to easier using * fix(Map): Add support new command for following update * fix(Map): Add support new command for main update * refactor(Core): Reduce map init data by using cached system static data * refactor(Core): Reduce map init data by extract signatures loading to a separate event * fix(Core): adjusted IP rate limits * fix(Map): Update design of tracking characters. Added icons for following and main. Added ability to see that character on the station or structure --------- Co-authored-by: achichenkov <aleksei.chichenkov@telleqt.ai> Co-authored-by: Dmitry Popov <dmitriypopovsamara@gmail.com>
110 lines
3.6 KiB
TypeScript
110 lines
3.6 KiB
TypeScript
import { useCallback, useMemo, useState } from 'react';
|
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
|
import { Widget } from '@/hooks/Mapper/components/mapInterface/components';
|
|
import { SystemKillsList } from './SystemKillsList';
|
|
import { KillsHeader } from './components/SystemKillsHeader';
|
|
import { useKillsWidgetSettings } from './hooks/useKillsWidgetSettings';
|
|
import { useSystemKills } from './hooks/useSystemKills';
|
|
import { KillsSettingsDialog } from './components/SystemKillsSettingsDialog';
|
|
import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace';
|
|
import { getSystemStaticInfo } from '@/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic';
|
|
|
|
const SystemKillsContent = () => {
|
|
const {
|
|
data: { selectedSystems, isSubscriptionActive },
|
|
outCommand,
|
|
} = useMapRootState();
|
|
|
|
const [systemId] = selectedSystems || [];
|
|
|
|
const systemStaticInfo = getSystemStaticInfo(systemId)!;
|
|
|
|
const [settings] = useKillsWidgetSettings();
|
|
const visible = settings.showAll;
|
|
|
|
const { kills, isLoading, error } = useSystemKills({
|
|
systemId,
|
|
outCommand,
|
|
showAllVisible: visible,
|
|
sinceHours: settings.timeRange,
|
|
});
|
|
|
|
const isNothingSelected = !systemId && !visible;
|
|
const showLoading = isLoading && kills.length === 0;
|
|
|
|
const filteredKills = useMemo(() => {
|
|
if (!settings.whOnly || !visible) return kills;
|
|
return kills.filter(kill => {
|
|
if (!systemStaticInfo) {
|
|
console.warn(`System with id ${kill.solar_system_id} not found.`);
|
|
return false;
|
|
}
|
|
return isWormholeSpace(systemStaticInfo.system_class);
|
|
});
|
|
}, [kills, settings.whOnly, systemStaticInfo, visible]);
|
|
|
|
if (!isSubscriptionActive) {
|
|
return (
|
|
<div className="w-full h-full flex items-center justify-center">
|
|
<span className="select-none text-center text-stone-400/80 text-sm">
|
|
Kills available with 'Active' map subscription only (contact map administrators)
|
|
</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (isNothingSelected) {
|
|
return (
|
|
<div className="w-full h-full flex items-center justify-center">
|
|
<span className="select-none text-center text-stone-400/80 text-sm">
|
|
No system selected (or toggle "Show all systems")
|
|
</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (showLoading) {
|
|
return (
|
|
<div className="w-full h-full flex items-center justify-center">
|
|
<span className="select-none text-center text-stone-400/80 text-sm">Loading Kills...</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (error) {
|
|
return (
|
|
<div className="w-full h-full flex items-center justify-center">
|
|
<span className="select-none text-center text-red-400 text-sm">{error}</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!filteredKills || filteredKills.length === 0) {
|
|
return (
|
|
<div className="w-full h-full flex items-center justify-center">
|
|
<span className="select-none text-center text-stone-400/80 text-sm">No kills found</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return <SystemKillsList kills={filteredKills} onlyOneSystem={!visible} timeRange={settings.timeRange} />;
|
|
};
|
|
|
|
export const WSystemKills = () => {
|
|
const [settingsDialogVisible, setSettingsDialogVisible] = useState(false);
|
|
const {
|
|
data: { selectedSystems },
|
|
} = useMapRootState();
|
|
|
|
const [systemId] = selectedSystems || [];
|
|
|
|
const handleOpenSettings = useCallback(() => setSettingsDialogVisible(true), []);
|
|
|
|
return (
|
|
<Widget label={<KillsHeader systemId={systemId} onOpenSettings={handleOpenSettings} />}>
|
|
<SystemKillsContent />
|
|
{settingsDialogVisible && <KillsSettingsDialog visible setVisible={setSettingsDialogVisible} />}
|
|
</Widget>
|
|
);
|
|
};
|