mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-12 10:45:54 +00:00
@@ -38,7 +38,7 @@ export const RoutesWidgetContent = () => {
|
|||||||
|
|
||||||
const { loading } = useLoadRoutes();
|
const { loading } = useLoadRoutes();
|
||||||
|
|
||||||
const { systems: systemStatics, loadSystems } = useLoadSystemStatic({ systems: hubs ?? [] });
|
const { systems: systemStatics, loadSystems, lastUpdateKey } = useLoadSystemStatic({ systems: hubs ?? [] });
|
||||||
const { open, ...systemCtxProps } = useContextMenuSystemInfoHandlers({
|
const { open, ...systemCtxProps } = useContextMenuSystemInfoHandlers({
|
||||||
outCommand,
|
outCommand,
|
||||||
hubs,
|
hubs,
|
||||||
@@ -51,7 +51,8 @@ export const RoutesWidgetContent = () => {
|
|||||||
|
|
||||||
return { ...systemStatics.get(parseInt(x))!, ...(sys && { customName: sys.name ?? '' }) };
|
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(() => {
|
const preparedRoutes = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -27,12 +27,14 @@ interface UseLoadSystemStaticProps {
|
|||||||
export const useLoadSystemStatic = ({ systems }: UseLoadSystemStaticProps) => {
|
export const useLoadSystemStatic = ({ systems }: UseLoadSystemStaticProps) => {
|
||||||
const { outCommand } = useMapRootState();
|
const { outCommand } = useMapRootState();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [lastUpdateKey, setLastUpdateKey] = useState(0);
|
||||||
|
|
||||||
const ref = useRef({ outCommand });
|
const ref = useRef({ outCommand });
|
||||||
ref.current = { outCommand };
|
ref.current = { outCommand };
|
||||||
|
|
||||||
const addSystemStatic = useCallback((static_info: SolarSystemStaticInfoRaw) => {
|
const addSystemStatic = useCallback((static_info: SolarSystemStaticInfoRaw) => {
|
||||||
cache.set(static_info.solar_system_id, static_info);
|
cache.set(static_info.solar_system_id, static_info);
|
||||||
|
setLastUpdateKey(new Date().getTime());
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const loadSystems = useCallback(async (systems: (number | string)[]) => {
|
const loadSystems = useCallback(async (systems: (number | string)[]) => {
|
||||||
@@ -43,6 +45,7 @@ export const useLoadSystemStatic = ({ systems }: UseLoadSystemStaticProps) => {
|
|||||||
if (toLoad.length > 0) {
|
if (toLoad.length > 0) {
|
||||||
const res = await loadSystemStaticInfo(ref.current.outCommand, toLoad);
|
const res = await loadSystemStaticInfo(ref.current.outCommand, toLoad);
|
||||||
res.forEach(x => cache.set(x.solar_system_id, x));
|
res.forEach(x => cache.set(x.solar_system_id, x));
|
||||||
|
setLastUpdateKey(new Date().getTime());
|
||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, []);
|
}, []);
|
||||||
@@ -52,5 +55,5 @@ export const useLoadSystemStatic = ({ systems }: UseLoadSystemStaticProps) => {
|
|||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, [systems]);
|
}, [systems]);
|
||||||
|
|
||||||
return { addSystemStatic, systems: cache, loading, loadSystems };
|
return { addSystemStatic, systems: cache, lastUpdateKey, loading, loadSystems };
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user