mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-12 02:35:42 +00:00
fix(Map): Fixed link signature modal crash afrer destination system removed
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
|
import { getSystemById } from '@/hooks/Mapper/helpers';
|
||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { getSystemById } from '@/hooks/Mapper/helpers';
|
|
||||||
import { getSystemStaticInfo } from '../../mapRootProvider/hooks/useLoadSystemStatic';
|
import { getSystemStaticInfo } from '../../mapRootProvider/hooks/useLoadSystemStatic';
|
||||||
|
|
||||||
interface UseSystemInfoProps {
|
interface UseSystemInfoProps {
|
||||||
@@ -17,7 +17,7 @@ export const useSystemInfo = ({ systemId }: UseSystemInfoProps) => {
|
|||||||
const dynamicInfo = getSystemById(systems, systemId);
|
const dynamicInfo = getSystemById(systems, systemId);
|
||||||
|
|
||||||
if (!staticInfo || !dynamicInfo) {
|
if (!staticInfo || !dynamicInfo) {
|
||||||
throw new Error(`Error on getting system ${systemId}`);
|
return { dynamicInfo, staticInfo, leadsTo: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
const leadsTo = connections
|
const leadsTo = connections
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
import { useCallback, useMemo, useRef } from 'react';
|
|
||||||
import { Dialog } from 'primereact/dialog';
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||||
|
|
||||||
import { OutCommand } from '@/hooks/Mapper/types/mapHandlers.ts';
|
|
||||||
import { CommandLinkSignatureToSystem, SignatureGroup, SystemSignature, TimeStatus } from '@/hooks/Mapper/types';
|
|
||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
|
||||||
import { SystemSignaturesContent } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignaturesContent';
|
|
||||||
import { parseSignatureCustomInfo } from '@/hooks/Mapper/helpers/parseSignatureCustomInfo';
|
|
||||||
import { getWhSize } from '@/hooks/Mapper/helpers/getWhSize';
|
|
||||||
import { useSystemInfo } from '@/hooks/Mapper/components/hooks';
|
import { useSystemInfo } from '@/hooks/Mapper/components/hooks';
|
||||||
import {
|
import {
|
||||||
SOLAR_SYSTEM_CLASS_IDS,
|
SOLAR_SYSTEM_CLASS_IDS,
|
||||||
SOLAR_SYSTEM_CLASSES_TO_CLASS_GROUPS,
|
SOLAR_SYSTEM_CLASSES_TO_CLASS_GROUPS,
|
||||||
WORMHOLES_ADDITIONAL_INFO_BY_SHORT_NAME,
|
WORMHOLES_ADDITIONAL_INFO_BY_SHORT_NAME,
|
||||||
} from '@/hooks/Mapper/components/map/constants.ts';
|
} from '@/hooks/Mapper/components/map/constants.ts';
|
||||||
import { K162_TYPES_MAP } from '@/hooks/Mapper/constants.ts';
|
|
||||||
import {
|
import {
|
||||||
SETTINGS_KEYS,
|
SETTINGS_KEYS,
|
||||||
SignatureSettingsType,
|
SignatureSettingsType,
|
||||||
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts';
|
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts';
|
||||||
|
import { SystemSignaturesContent } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignaturesContent';
|
||||||
|
import { K162_TYPES_MAP } from '@/hooks/Mapper/constants.ts';
|
||||||
|
import { getWhSize } from '@/hooks/Mapper/helpers/getWhSize';
|
||||||
|
import { parseSignatureCustomInfo } from '@/hooks/Mapper/helpers/parseSignatureCustomInfo';
|
||||||
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
|
import { CommandLinkSignatureToSystem, SignatureGroup, SystemSignature, TimeStatus } from '@/hooks/Mapper/types';
|
||||||
|
import { OutCommand } from '@/hooks/Mapper/types/mapHandlers.ts';
|
||||||
|
|
||||||
const K162_SIGNATURE_TYPE = WORMHOLES_ADDITIONAL_INFO_BY_SHORT_NAME['K162'].shortName;
|
const K162_SIGNATURE_TYPE = WORMHOLES_ADDITIONAL_INFO_BY_SHORT_NAME['K162'].shortName;
|
||||||
|
|
||||||
@@ -49,7 +49,9 @@ export const SystemLinkSignatureDialog = ({ data, setVisible }: SystemLinkSignat
|
|||||||
ref.current = { outCommand };
|
ref.current = { outCommand };
|
||||||
|
|
||||||
// Get system info for the target system
|
// Get system info for the target system
|
||||||
const { staticInfo: targetSystemInfo } = useSystemInfo({ systemId: `${data.solar_system_target}` });
|
const { staticInfo: targetSystemInfo, dynamicInfo: targetSystemDynamicInfo } = useSystemInfo({
|
||||||
|
systemId: `${data.solar_system_target}`,
|
||||||
|
});
|
||||||
|
|
||||||
// Get the system class group for the target system
|
// Get the system class group for the target system
|
||||||
const targetSystemClassGroup = useMemo(() => {
|
const targetSystemClassGroup = useMemo(() => {
|
||||||
@@ -160,6 +162,12 @@ export const SystemLinkSignatureDialog = ({ data, setVisible }: SystemLinkSignat
|
|||||||
[data, setVisible, wormholes],
|
[data, setVisible, wormholes],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!targetSystemDynamicInfo) {
|
||||||
|
handleHide();
|
||||||
|
}
|
||||||
|
}, [targetSystemDynamicInfo]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
header="Select signature to link"
|
header="Select signature to link"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { MapHandlers } from '@/hooks/Mapper/types/mapHandlers.ts';
|
import { MapHandlers } from '@/hooks/Mapper/types/mapHandlers.ts';
|
||||||
import { RefObject, useCallback } from 'react';
|
import { RefObject, useCallback } from 'react';
|
||||||
|
|
||||||
// Force reload the page after 30 minutes of inactivity
|
// Force reload the page after 5 minutes of inactivity
|
||||||
const FORCE_PAGE_RELOAD_TIMEOUT = 1000 * 60 * 30;
|
const FORCE_PAGE_RELOAD_TIMEOUT = 1000 * 60 * 5;
|
||||||
|
|
||||||
export const useMapperHandlers = (handlerRefs: RefObject<MapHandlers>[], hooksRef: RefObject<any>) => {
|
export const useMapperHandlers = (handlerRefs: RefObject<MapHandlers>[], hooksRef: RefObject<any>) => {
|
||||||
const handleCommand = useCallback(
|
const handleCommand = useCallback(
|
||||||
|
|||||||
Reference in New Issue
Block a user