This commit is contained in:
PxlLoewe
2025-07-07 02:38:06 -07:00
parent 79a65d690c
commit 79b26be39a
5 changed files with 27 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ import { HPGnotificationToast } from "_components/customToasts/HPGnotification";
import { useMapStore } from "_store/mapStore";
import { AdminMessageToast } from "_components/customToasts/AdminMessage";
import { pilotSocket } from "(app)/pilot/socket";
import { StatusToast } from "_components/customToasts/StationStatusToast";
import { QUICK_RESPONSE, StatusToast } from "_components/customToasts/StationStatusToast";
export function QueryProvider({ children }: { children: ReactNode }) {
const mapStore = useMapStore((s) => s);
@@ -76,7 +76,7 @@ export function QueryProvider({ children }: { children: ReactNode }) {
});
break;
case "station-status":
if (notification.status !== "5") return;
if (!QUICK_RESPONSE[notification.status]) return;
toast.custom((e) => <StatusToast event={notification} t={e} />, {
duration: 60000,
});

View File

@@ -6,13 +6,25 @@ import { editConnectedAircraftAPI, getConnectedAircraftsAPI } from "_querys/airc
import { getStationsAPI } from "_querys/stations";
import { useMapStore } from "_store/mapStore";
import { X } from "lucide-react";
import { useEffect, useRef } from "react";
import { Toast, toast } from "react-hot-toast";
const QUICK_RESPONSE: Record<string, string[]> = {
export const QUICK_RESPONSE: Record<string, string[]> = {
"5": ["J", "c"],
"0": ["J", "c"],
};
export const StatusToast = ({ event, t }: { event: StationStatus; t: Toast }) => {
const status0Sounds = useRef<HTMLAudioElement | null>(null);
const status5Sounds = useRef<HTMLAudioElement | null>(null);
useEffect(() => {
if (typeof window !== "undefined") {
status0Sounds.current = new Audio("/sounds/status-0.mp3");
status5Sounds.current = new Audio("/sounds/status-5.mp3");
}
}, []);
const mapStore = useMapStore((s) => s);
const { data: connectedAircrafts } = useQuery({
@@ -44,6 +56,18 @@ export const StatusToast = ({ event, t }: { event: StationStatus; t: Toast }) =>
const connectedAircraft = connectedAircrafts?.find((a) => a.id === event.data?.aircraftId);
const station = stations?.find((s) => s.id === event.data?.stationId);
useEffect(() => {
if (connectedAircraft?.fmsStatus === "0" && status0Sounds.current) {
status0Sounds.current.currentTime = 0;
status0Sounds.current.volume = 0.7;
status0Sounds.current.play();
} else if (connectedAircraft?.fmsStatus === "5" && status5Sounds.current) {
status5Sounds.current.currentTime = 0;
status5Sounds.current.volume = 0.7;
status5Sounds.current.play();
}
}, [connectedAircraft?.fmsStatus]);
if (!connectedAircraft || !station) return null;
return (
<BaseNotification>

Binary file not shown.

Binary file not shown.

Binary file not shown.