Refactoring and fixing problems (#317)

* 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>
This commit is contained in:
Aleksei Chichenkov
2025-04-11 22:17:53 +03:00
committed by GitHub
parent 7da5512d45
commit d8222d83f0
126 changed files with 3372 additions and 2647 deletions

View File

@@ -1,10 +1,12 @@
import { ContextStoreDataUpdate, useContextStore } from '@/hooks/Mapper/utils';
import { createContext, Dispatch, ForwardedRef, forwardRef, SetStateAction, useContext, useEffect } from 'react';
import {
ActivitySummary,
CommandLinkSignatureToSystem,
MapUnionTypes,
OutCommandHandler,
SolarSystemConnection,
TrackingCharacter,
UseCharactersCacheData,
UseCommentsData,
} from '@/hooks/Mapper/types';
@@ -18,8 +20,6 @@ import {
} from '@/hooks/Mapper/mapRootProvider/hooks/useStoreWidgets.ts';
import { WindowsManagerOnChange } from '@/hooks/Mapper/components/ui-kit/WindowManager';
import { DetailedKill } from '../types/kills';
import { ActivitySummary } from '../components/mapRootContent/components/CharacterActivity';
import { TrackingCharacter } from '../components/mapRootContent/components/TrackAndFollow/types';
export type MapRootData = MapUnionTypes & {
selectedSystems: string[];
@@ -31,7 +31,6 @@ export type MapRootData = MapUnionTypes & {
activity: ActivitySummary[];
loading?: boolean;
};
showTrackAndFollow: boolean;
trackingCharactersData: TrackingCharacter[];
};
@@ -45,7 +44,6 @@ const INITIAL_DATA: MapRootData = {
activity: [],
loading: false,
},
showTrackAndFollow: false,
trackingCharactersData: [],
userCharacters: [],
presentCharacters: [],
@@ -62,6 +60,8 @@ const INITIAL_DATA: MapRootData = {
options: {},
isSubscriptionActive: false,
linkSignatureToSystem: null,
mainCharacterEveId: null,
followingCharacterEveId: null,
};
export enum AvailableThemes {
@@ -166,6 +166,8 @@ export const MapRootProvider = ({ children, fwdRef, outCommand }: MapRootProvide
},
);
const { windowsSettings, toggleWidgetVisibility, updateWidgetSettings, resetWidgets } = useStoreWidgets();
const comments = useComments({ outCommand });
const charactersCache = useCharactersCache({ outCommand });
useEffect(() => {
let foundNew = false;
@@ -183,11 +185,9 @@ export const MapRootProvider = ({ children, fwdRef, outCommand }: MapRootProvide
if (foundNew) {
setInterfaceSettings(newVals);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const comments = useComments({ outCommand });
const charactersCache = useCharactersCache({ outCommand });
return (
<MapRootContext.Provider
value={{

View File

@@ -11,6 +11,7 @@ export const useMapInit = () => {
return useCallback(
({
systems,
system_signatures,
connections,
effects,
wormholes,
@@ -22,6 +23,8 @@ export const useMapInit = () => {
user_permissions,
options,
is_subscription_active,
main_character_eve_id,
following_character_eve_id,
}: CommandInit) => {
const updateData: Partial<MapRootData> = {};
@@ -50,6 +53,10 @@ export const useMapInit = () => {
updateData.systems = systems;
}
if (system_signatures) {
updateData.systemSignatures = system_signatures;
}
if (connections) {
updateData.connections = connections;
}
@@ -66,7 +73,9 @@ export const useMapInit = () => {
updateData.options = options;
}
updateData.isSubscriptionActive = is_subscription_active;
if (is_subscription_active) {
updateData.isSubscriptionActive = is_subscription_active;
}
if (system_static_infos) {
system_static_infos.forEach(static_info => {
@@ -74,6 +83,14 @@ export const useMapInit = () => {
});
}
if (main_character_eve_id) {
updateData.mainCharacterEveId = main_character_eve_id;
}
if (following_character_eve_id) {
updateData.followingCharacterEveId = following_character_eve_id;
}
update(updateData);
},
[update, addSystemStatic],

View File

@@ -9,6 +9,13 @@ type SystemStaticResult = {
// TODO maybe later we can store in Static data in provider
const cache = new Map<number, SolarSystemStaticInfoRaw>();
export const getSystemStaticInfo = (solarSystemId: number | string | undefined) => {
if (!solarSystemId) {
return;
}
return cache.get(typeof solarSystemId == 'number' ? solarSystemId : parseInt(solarSystemId));
};
export const loadSystemStaticInfo = async (outCommand: OutCommandHandler, systems: number[]) => {
const result = await outCommand({
type: OutCommand.getSystemStaticInfos,

View File

@@ -57,112 +57,116 @@ export const useMapRootHandlers = (ref: ForwardedRef<MapHandlers>) => {
const { addComment, removeComment } = useCommandComments();
const { characterActivityData, trackingCharactersData, userSettingsUpdated } = useCommandsActivity();
useImperativeHandle(ref, () => {
return {
command(type, data) {
switch (type) {
case Commands.init: // USED
mapInit(data as CommandInit);
break;
case Commands.addSystems: // USED
addSystems(data as CommandAddSystems);
break;
case Commands.updateSystems: // USED
updateSystems(data as CommandUpdateSystems);
break;
case Commands.removeSystems: // USED
removeSystems(data as CommandRemoveSystems);
break;
case Commands.addConnections: // USED
addConnections(data as CommandAddConnections);
break;
case Commands.removeConnections: // USED
removeConnections(data as CommandRemoveConnections);
break;
case Commands.updateConnection: // USED
updateConnection(data as CommandUpdateConnection);
break;
case Commands.charactersUpdated: // USED
charactersUpdated(data as CommandCharactersUpdated);
break;
case Commands.characterAdded: // USED
characterAdded(data as CommandCharacterAdded);
break;
case Commands.characterRemoved: // USED
characterRemoved(data as CommandCharacterRemoved);
break;
case Commands.characterUpdated: // USED
characterUpdated(data as CommandCharacterUpdated);
break;
case Commands.presentCharacters: // USED
presentCharacters(data as CommandPresentCharacters);
break;
case Commands.mapUpdated: // USED
mapUpdated(data as CommandMapUpdated);
break;
case Commands.routes:
mapRoutes(data as CommandRoutes);
break;
useImperativeHandle(
ref,
() => {
return {
command(type, data) {
switch (type) {
case Commands.init: // USED
mapInit(data as CommandInit);
break;
case Commands.addSystems: // USED
addSystems(data as CommandAddSystems);
break;
case Commands.updateSystems: // USED
updateSystems(data as CommandUpdateSystems);
break;
case Commands.removeSystems: // USED
removeSystems(data as CommandRemoveSystems);
break;
case Commands.addConnections: // USED
addConnections(data as CommandAddConnections);
break;
case Commands.removeConnections: // USED
removeConnections(data as CommandRemoveConnections);
break;
case Commands.updateConnection: // USED
updateConnection(data as CommandUpdateConnection);
break;
case Commands.charactersUpdated: // USED
charactersUpdated(data as CommandCharactersUpdated);
break;
case Commands.characterAdded: // USED
characterAdded(data as CommandCharacterAdded);
break;
case Commands.characterRemoved: // USED
characterRemoved(data as CommandCharacterRemoved);
break;
case Commands.characterUpdated: // USED
characterUpdated(data as CommandCharacterUpdated);
break;
case Commands.presentCharacters: // USED
presentCharacters(data as CommandPresentCharacters);
break;
case Commands.mapUpdated: // USED
mapUpdated(data as CommandMapUpdated);
break;
case Commands.routes:
mapRoutes(data as CommandRoutes);
break;
case Commands.signaturesUpdated: // USED
updateSystemSignatures(data as CommandSignaturesUpdated);
break;
case Commands.signaturesUpdated: // USED
updateSystemSignatures(data as CommandSignaturesUpdated);
break;
case Commands.linkSignatureToSystem: // USED
setTimeout(() => {
updateLinkSignatureToSystem(data as CommandLinkSignatureToSystem);
}, 200);
break;
case Commands.linkSignatureToSystem: // USED
setTimeout(() => {
updateLinkSignatureToSystem(data as CommandLinkSignatureToSystem);
}, 200);
break;
case Commands.centerSystem: // USED
// do nothing here
break;
case Commands.centerSystem: // USED
// do nothing here
break;
case Commands.selectSystem: // USED
// do nothing here
break;
case Commands.selectSystem: // USED
// do nothing here
break;
case Commands.killsUpdated:
// do nothing here
break;
case Commands.killsUpdated:
// do nothing here
break;
case Commands.detailedKillsUpdated:
updateDetailedKills(data as Record<string, DetailedKill[]>);
break;
case Commands.detailedKillsUpdated:
updateDetailedKills(data as Record<string, DetailedKill[]>);
break;
case Commands.characterActivityData:
characterActivityData(data as CommandCharacterActivityData);
break;
case Commands.characterActivityData:
characterActivityData(data as CommandCharacterActivityData);
break;
case Commands.trackingCharactersData:
trackingCharactersData(data as CommandTrackingCharactersData);
break;
case Commands.trackingCharactersData:
trackingCharactersData(data as CommandTrackingCharactersData);
break;
case Commands.updateActivity:
break;
case Commands.updateActivity:
break;
case Commands.updateTracking:
break;
case Commands.updateTracking:
break;
case Commands.userSettingsUpdated:
userSettingsUpdated(data as CommandUserSettingsUpdated);
break;
case Commands.userSettingsUpdated:
userSettingsUpdated(data as CommandUserSettingsUpdated);
break;
case Commands.systemCommentAdded:
addComment(data as CommandCommentAdd);
break;
case Commands.systemCommentAdded:
addComment(data as CommandCommentAdd);
break;
case Commands.systemCommentRemoved:
removeComment(data as CommandCommentRemoved);
break;
case Commands.systemCommentRemoved:
removeComment(data as CommandCommentRemoved);
break;
default:
console.warn(`JOipP Interface handlers: Unknown command: ${type}`, data);
break;
}
default:
console.warn(`JOipP Interface handlers: Unknown command: ${type}`, data);
break;
}
emitMapEvent({ name: type, data });
},
};
}, []);
emitMapEvent({ name: type, data });
},
};
},
[],
);
};