diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesWidget.tsx b/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesWidget.tsx index 0300966b..50922311 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesWidget.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesWidget.tsx @@ -38,7 +38,7 @@ export const RoutesWidgetContent = () => { const { loading } = useLoadRoutes(); - const { systems: systemStatics, loadSystems } = useLoadSystemStatic({ systems: hubs ?? [] }); + const { systems: systemStatics, loadSystems, lastUpdateKey } = useLoadSystemStatic({ systems: hubs ?? [] }); const { open, ...systemCtxProps } = useContextMenuSystemInfoHandlers({ outCommand, hubs, @@ -51,7 +51,8 @@ export const RoutesWidgetContent = () => { return { ...systemStatics.get(parseInt(x))!, ...(sys && { customName: sys.name ?? '' }) }; }); - }, [hubs, systems, systemStatics]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [hubs, systems, systemStatics, lastUpdateKey]); const preparedRoutes = useMemo(() => { return ( diff --git a/assets/js/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic.ts b/assets/js/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic.ts index 4bb82f52..05d2ccad 100644 --- a/assets/js/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic.ts +++ b/assets/js/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic.ts @@ -27,12 +27,14 @@ interface UseLoadSystemStaticProps { export const useLoadSystemStatic = ({ systems }: UseLoadSystemStaticProps) => { const { outCommand } = useMapRootState(); const [loading, setLoading] = useState(false); + const [lastUpdateKey, setLastUpdateKey] = useState(0); const ref = useRef({ outCommand }); ref.current = { outCommand }; const addSystemStatic = useCallback((static_info: SolarSystemStaticInfoRaw) => { cache.set(static_info.solar_system_id, static_info); + setLastUpdateKey(new Date().getTime()); }, []); const loadSystems = useCallback(async (systems: (number | string)[]) => { @@ -43,6 +45,7 @@ export const useLoadSystemStatic = ({ systems }: UseLoadSystemStaticProps) => { if (toLoad.length > 0) { const res = await loadSystemStaticInfo(ref.current.outCommand, toLoad); res.forEach(x => cache.set(x.solar_system_id, x)); + setLastUpdateKey(new Date().getTime()); } setLoading(false); }, []); @@ -52,5 +55,5 @@ export const useLoadSystemStatic = ({ systems }: UseLoadSystemStaticProps) => { // eslint-disable-next-line }, [systems]); - return { addSystemStatic, systems: cache, loading, loadSystems }; + return { addSystemStatic, systems: cache, lastUpdateKey, loading, loadSystems }; };