Check sim enhancement
This commit is contained in:
@@ -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 (
|
||||
<div className="relative flex-1 flex transition-all duration-500 ease w-full h-screen overflow-hidden">
|
||||
|
||||
Reference in New Issue
Block a user