Check sim enhancement
This commit is contained in:
@@ -8,7 +8,7 @@ import dynamic from "next/dynamic";
|
|||||||
import { ConnectedDispatcher } from "tracker/_components/ConnectedDispatcher";
|
import { ConnectedDispatcher } from "tracker/_components/ConnectedDispatcher";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
||||||
import { getAircraftsAPI } from "_querys/aircrafts";
|
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
||||||
import { checkSimulatorConnected } from "@repo/shared-components";
|
import { checkSimulatorConnected } from "@repo/shared-components";
|
||||||
import { SimConnectionAlert } from "(app)/pilot/_components/SimConnectionAlert";
|
import { SimConnectionAlert } from "(app)/pilot/_components/SimConnectionAlert";
|
||||||
|
|
||||||
@@ -18,15 +18,14 @@ const Map = dynamic(() => import("_components/map/Map"), {
|
|||||||
|
|
||||||
const PilotPage = () => {
|
const PilotPage = () => {
|
||||||
const { connectedAircraft, status } = usePilotConnectionStore((state) => state);
|
const { connectedAircraft, status } = usePilotConnectionStore((state) => state);
|
||||||
const { data: ownAircraftArray = [] } = useQuery({
|
// Query will be cached anyway, due to this, displayed Markers are in sync with own Aircraft connection-warning
|
||||||
queryKey: ["own-aircraft", connectedAircraft?.id],
|
const { data: aircrafts } = useQuery({
|
||||||
queryFn: () =>
|
queryKey: ["aircrafts"],
|
||||||
getAircraftsAPI({
|
queryFn: () => getConnectedAircraftsAPI(),
|
||||||
id: connectedAircraft?.id,
|
refetchInterval: 10_000,
|
||||||
}),
|
|
||||||
refetchInterval: 10000,
|
|
||||||
});
|
});
|
||||||
const ownAircraft = ownAircraftArray[0];
|
|
||||||
|
const ownAircraft = aircrafts?.find((aircraft) => aircraft.id === connectedAircraft?.id);
|
||||||
const simulatorConnected = ownAircraft ? checkSimulatorConnected(ownAircraft) : false;
|
const simulatorConnected = ownAircraft ? checkSimulatorConnected(ownAircraft) : false;
|
||||||
return (
|
return (
|
||||||
<div className="relative flex-1 flex transition-all duration-500 ease w-full h-screen overflow-hidden">
|
<div className="relative flex-1 flex transition-all duration-500 ease w-full h-screen overflow-hidden">
|
||||||
|
|||||||
Reference in New Issue
Block a user