From 0730737bbe4416810661d0260c94b2b80d0aca9c Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Sat, 12 Jul 2025 19:43:32 -0700 Subject: [PATCH] Check sim enhancement --- apps/dispatch/app/(app)/pilot/page.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/dispatch/app/(app)/pilot/page.tsx b/apps/dispatch/app/(app)/pilot/page.tsx index e72bf3e9..5e31f982 100644 --- a/apps/dispatch/app/(app)/pilot/page.tsx +++ b/apps/dispatch/app/(app)/pilot/page.tsx @@ -8,7 +8,7 @@ import dynamic from "next/dynamic"; import { ConnectedDispatcher } from "tracker/_components/ConnectedDispatcher"; import { useQuery } from "@tanstack/react-query"; import { usePilotConnectionStore } from "_store/pilot/connectionStore"; -import { getAircraftsAPI } from "_querys/aircrafts"; +import { getConnectedAircraftsAPI } from "_querys/aircrafts"; import { checkSimulatorConnected } from "@repo/shared-components"; import { SimConnectionAlert } from "(app)/pilot/_components/SimConnectionAlert"; @@ -18,15 +18,14 @@ const Map = dynamic(() => import("_components/map/Map"), { const PilotPage = () => { const { connectedAircraft, status } = usePilotConnectionStore((state) => state); - const { data: ownAircraftArray = [] } = useQuery({ - queryKey: ["own-aircraft", connectedAircraft?.id], - queryFn: () => - getAircraftsAPI({ - id: connectedAircraft?.id, - }), - refetchInterval: 10000, + // Query will be cached anyway, due to this, displayed Markers are in sync with own Aircraft connection-warning + const { data: aircrafts } = useQuery({ + queryKey: ["aircrafts"], + queryFn: () => getConnectedAircraftsAPI(), + refetchInterval: 10_000, }); - const ownAircraft = ownAircraftArray[0]; + + const ownAircraft = aircrafts?.find((aircraft) => aircraft.id === connectedAircraft?.id); const simulatorConnected = ownAircraft ? checkSimulatorConnected(ownAircraft) : false; return (