fix(Core): Fixed system select after tab switch

This commit is contained in:
Dmitry Popov
2025-10-15 14:30:19 +02:00
parent 245647ae6a
commit 3fb22a877e
3 changed files with 91 additions and 107 deletions

View File

@@ -49,91 +49,87 @@ export const useMapHandlers = (ref: ForwardedRef<MapHandlers>, onSelectionChange
const { charactersUpdated, presentCharacters, characterAdded, characterRemoved, characterUpdated } = const { charactersUpdated, presentCharacters, characterAdded, characterRemoved, characterUpdated } =
useCommandsCharacters(); useCommandsCharacters();
useImperativeHandle( useImperativeHandle(ref, () => {
ref, return {
() => { command(type, data) {
return { switch (type) {
command(type, data) { case Commands.init:
switch (type) { mapInit(data as CommandInit);
case Commands.init: break;
mapInit(data as CommandInit); case Commands.addSystems:
break; setTimeout(() => mapAddSystems(data as CommandAddSystems), 100);
case Commands.addSystems: break;
setTimeout(() => mapAddSystems(data as CommandAddSystems), 100); case Commands.updateSystems:
break; mapUpdateSystems(data as CommandUpdateSystems);
case Commands.updateSystems: break;
mapUpdateSystems(data as CommandUpdateSystems); case Commands.removeSystems:
break; setTimeout(() => removeSystems(data as CommandRemoveSystems), 100);
case Commands.removeSystems: break;
setTimeout(() => removeSystems(data as CommandRemoveSystems), 100); case Commands.addConnections:
break; setTimeout(() => addConnections(data as CommandAddConnections), 100);
case Commands.addConnections: break;
setTimeout(() => addConnections(data as CommandAddConnections), 100); case Commands.removeConnections:
break; setTimeout(() => removeConnections(data as CommandRemoveConnections), 100);
case Commands.removeConnections: break;
setTimeout(() => removeConnections(data as CommandRemoveConnections), 100); case Commands.charactersUpdated:
break; charactersUpdated(data as CommandCharactersUpdated);
case Commands.charactersUpdated: break;
charactersUpdated(data as CommandCharactersUpdated); case Commands.characterAdded:
break; characterAdded(data as CommandCharacterAdded);
case Commands.characterAdded: break;
characterAdded(data as CommandCharacterAdded); case Commands.characterRemoved:
break; characterRemoved(data as CommandCharacterRemoved);
case Commands.characterRemoved: break;
characterRemoved(data as CommandCharacterRemoved); case Commands.characterUpdated:
break; characterUpdated(data as CommandCharacterUpdated);
case Commands.characterUpdated: break;
characterUpdated(data as CommandCharacterUpdated); case Commands.presentCharacters:
break; presentCharacters(data as CommandPresentCharacters);
case Commands.presentCharacters: break;
presentCharacters(data as CommandPresentCharacters); case Commands.updateConnection:
break; updateConnection(data as CommandUpdateConnection);
case Commands.updateConnection: break;
updateConnection(data as CommandUpdateConnection); case Commands.mapUpdated:
break; mapUpdated(data as CommandMapUpdated);
case Commands.mapUpdated: break;
mapUpdated(data as CommandMapUpdated); case Commands.killsUpdated:
break; killsUpdated(data as CommandKillsUpdated);
case Commands.killsUpdated: break;
killsUpdated(data as CommandKillsUpdated);
break;
case Commands.centerSystem: case Commands.centerSystem:
setTimeout(() => { setTimeout(() => {
const systemId = `${data}`; const systemId = `${data}`;
centerSystem(systemId as CommandSelectSystem); centerSystem(systemId as CommandSelectSystem);
}, 100); }, 100);
break; break;
case Commands.selectSystem: case Commands.selectSystem:
selectSystems({ systems: [data as string], delay: 500 }); selectSystems({ systems: [data as string], delay: 500 });
break; break;
case Commands.selectSystems: case Commands.selectSystems:
selectSystems(data as CommandSelectSystems); selectSystems(data as CommandSelectSystems);
break; break;
case Commands.pingAdded: case Commands.pingAdded:
case Commands.pingCancelled: case Commands.pingCancelled:
case Commands.routes: case Commands.routes:
case Commands.signaturesUpdated: case Commands.signaturesUpdated:
case Commands.linkSignatureToSystem: case Commands.linkSignatureToSystem:
case Commands.detailedKillsUpdated: case Commands.detailedKillsUpdated:
case Commands.characterActivityData: case Commands.characterActivityData:
case Commands.trackingCharactersData: case Commands.trackingCharactersData:
case Commands.updateActivity: case Commands.updateActivity:
case Commands.updateTracking: case Commands.updateTracking:
case Commands.userSettingsUpdated: case Commands.userSettingsUpdated:
// do nothing // do nothing
break; break;
default: default:
console.warn(`Map handlers: Unknown command: ${type}`, data); console.warn(`Map handlers: Unknown command: ${type}`, data);
break; break;
} }
}, },
}; };
}, }, []);
[],
);
}; };

View File

@@ -1,36 +1,36 @@
import { Map, MAP_ROOT_ID } from '@/hooks/Mapper/components/map/Map.tsx';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { CommandSelectSystems, OutCommand, OutCommandHandler, SolarSystemConnection } from '@/hooks/Mapper/types';
import { MapRootData, useMapRootState } from '@/hooks/Mapper/mapRootProvider';
import { OnMapAddSystemCallback, OnMapSelectionChange } from '@/hooks/Mapper/components/map/map.types.ts';
import isEqual from 'lodash.isequal';
import { ContextMenuSystem, useContextMenuSystemHandlers } from '@/hooks/Mapper/components/contexts'; import { ContextMenuSystem, useContextMenuSystemHandlers } from '@/hooks/Mapper/components/contexts';
import { Map, MAP_ROOT_ID } from '@/hooks/Mapper/components/map/Map.tsx';
import { OnMapAddSystemCallback, OnMapSelectionChange } from '@/hooks/Mapper/components/map/map.types.ts';
import { import {
SystemCustomLabelDialog, SystemCustomLabelDialog,
SystemLinkSignatureDialog, SystemLinkSignatureDialog,
SystemSettingsDialog, SystemSettingsDialog,
} from '@/hooks/Mapper/components/mapInterface/components'; } from '@/hooks/Mapper/components/mapInterface/components';
import { Connections } from '@/hooks/Mapper/components/mapRootContent/components/Connections'; import { Connections } from '@/hooks/Mapper/components/mapRootContent/components/Connections';
import { ContextMenuSystemMultiple, useContextMenuSystemMultipleHandlers } from '../contexts/ContextMenuSystemMultiple';
import { getSystemById } from '@/hooks/Mapper/helpers'; import { getSystemById } from '@/hooks/Mapper/helpers';
import { MapRootData, useMapRootState } from '@/hooks/Mapper/mapRootProvider';
import { CommandSelectSystems, OutCommand, OutCommandHandler, SolarSystemConnection } from '@/hooks/Mapper/types';
import { Commands } from '@/hooks/Mapper/types/mapHandlers.ts'; import { Commands } from '@/hooks/Mapper/types/mapHandlers.ts';
import isEqual from 'lodash.isequal';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Node, useReactFlow, Viewport, XYPosition } from 'reactflow'; import { Node, useReactFlow, Viewport, XYPosition } from 'reactflow';
import { ContextMenuSystemMultiple, useContextMenuSystemMultipleHandlers } from '../contexts/ContextMenuSystemMultiple';
import { useCommandsSystems } from '@/hooks/Mapper/mapRootProvider/hooks/api';
import { emitMapEvent, useMapEventListener } from '@/hooks/Mapper/events'; import { emitMapEvent, useMapEventListener } from '@/hooks/Mapper/events';
import { useCommandsSystems } from '@/hooks/Mapper/mapRootProvider/hooks/api';
import { useDeleteSystems } from '@/hooks/Mapper/components/contexts/hooks'; import { useDeleteSystems } from '@/hooks/Mapper/components/contexts/hooks';
import { useCommonMapEventProcessor } from '@/hooks/Mapper/components/mapWrapper/hooks/useCommonMapEventProcessor.ts';
import { import {
AddSystemDialog, AddSystemDialog,
SearchOnSubmitCallback, SearchOnSubmitCallback,
} from '@/hooks/Mapper/components/mapInterface/components/AddSystemDialog'; } from '@/hooks/Mapper/components/mapInterface/components/AddSystemDialog';
import { useHotkey } from '../../hooks/useHotkey';
import { PingType } from '@/hooks/Mapper/types/ping.ts';
import { SystemPingDialog } from '@/hooks/Mapper/components/mapInterface/components/SystemPingDialog'; import { SystemPingDialog } from '@/hooks/Mapper/components/mapInterface/components/SystemPingDialog';
import { MiniMapPlacement } from '@/hooks/Mapper/mapRootProvider/types.ts'; import { useCommonMapEventProcessor } from '@/hooks/Mapper/components/mapWrapper/hooks/useCommonMapEventProcessor.ts';
import { MINIMAP_PLACEMENT_MAP } from '@/hooks/Mapper/constants.ts'; import { MINIMAP_PLACEMENT_MAP } from '@/hooks/Mapper/constants.ts';
import { MiniMapPlacement } from '@/hooks/Mapper/mapRootProvider/types.ts';
import { PingType } from '@/hooks/Mapper/types/ping.ts';
import type { PanelPosition } from '@reactflow/core'; import type { PanelPosition } from '@reactflow/core';
import { useHotkey } from '../../hooks/useHotkey';
import { MINI_MAP_PLACEMENT_OFFSETS } from './constants.ts'; import { MINI_MAP_PLACEMENT_OFFSETS } from './constants.ts';
// TODO: INFO - this component needs for abstract work with Map instance // TODO: INFO - this component needs for abstract work with Map instance
@@ -106,7 +106,7 @@ export const MapWrapper = () => {
runCommand({ runCommand({
name: Commands.selectSystems, name: Commands.selectSystems,
data: { systems: selectedSystems } as CommandSelectSystems, data: { systems: selectedSystems, delay: 200 } as CommandSelectSystems,
}); });
} }
}); });

View File

@@ -703,18 +703,6 @@ defmodule WandererAppWeb.MapCoreEventHandler do
Process.send_after(self(), %{event: :load_map_pings}, 200) Process.send_after(self(), %{event: :load_map_pings}, 200)
Process.send_after(
self(),
%{
event: :maybe_select_system,
payload: %{
character_id: nil,
solar_system_id: nil
}
},
200
)
if needs_tracking_setup do if needs_tracking_setup do
Process.send_after(self(), %{event: :show_tracking}, 10) Process.send_after(self(), %{event: :show_tracking}, 10)