diff --git a/apps/dispatch/app/_components/Audio/Audio.tsx b/apps/dispatch/app/_components/Audio/Audio.tsx index ca8698b8..46d96120 100644 --- a/apps/dispatch/app/_components/Audio/Audio.tsx +++ b/apps/dispatch/app/_components/Audio/Audio.tsx @@ -27,6 +27,7 @@ export const Audio = () => { speakingParticipants, isTalking, toggleTalking, + transmitBlocked, connect, state, connectionQuality, @@ -41,6 +42,7 @@ export const Audio = () => { isReceiving: speakingParticipants.length > 0, isTransmitting: isTalking, unpausedTracks: speakingParticipants, + transmitBlocked, }); const { selectedStation, status: pilotState } = usePilotConnectionStore((state) => state); @@ -154,6 +156,7 @@ export const Audio = () => { "btn btn-sm btn-soft border-none hover:bg-inherit", !isTalking && "bg-transparent hover:bg-sky-400/20", isTalking && "bg-green-700 hover:bg-green-600", + transmitBlocked && "bg-yellow-500 hover:bg-yellow-500", state === "disconnected" && "bg-red-500 hover:bg-red-500", state === "error" && "bg-red-500 hover:bg-red-500", state === "connecting" && "bg-yellow-500 hover:bg-yellow-500 cursor-default", diff --git a/apps/dispatch/app/_components/Audio/useSounds.ts b/apps/dispatch/app/_components/Audio/useSounds.ts index 8570dda3..9a7e8acd 100644 --- a/apps/dispatch/app/_components/Audio/useSounds.ts +++ b/apps/dispatch/app/_components/Audio/useSounds.ts @@ -7,10 +7,12 @@ export const useSounds = ({ isReceiving, isTransmitting, unpausedTracks, + transmitBlocked, }: { isReceiving: boolean; isTransmitting: boolean; unpausedTracks: unknown[]; + transmitBlocked?: boolean; }) => { const { room } = useAudioStore(); // Sounds as refs @@ -56,6 +58,17 @@ export const useSounds = ({ } }, [isReceiving, isTransmitting, soundConnectionStarted]); + useEffect(() => { + if (transmitBlocked && foreignCallBlocked.current) { + foreignCallBlocked.current.volume = 0.2; + foreignCallBlocked.current.currentTime = 0; + foreignCallBlocked.current.loop = true; + foreignCallBlocked.current.play().catch(() => {}); + } else if (foreignCallBlocked.current) { + foreignCallBlocked.current.pause(); + } + }, [transmitBlocked]); + useEffect(() => { if (isTransmitting && connectionStart.current!.paused) { ownCallStarted.current!.volume = 0.2; diff --git a/apps/dispatch/app/_components/left/Chat.tsx b/apps/dispatch/app/_components/left/Chat.tsx index 3b78e02b..bcf1b61d 100644 --- a/apps/dispatch/app/_components/left/Chat.tsx +++ b/apps/dispatch/app/_components/left/Chat.tsx @@ -39,7 +39,7 @@ export const Chat = () => { }); useEffect(() => { - if(!session.data?.user.id) return; + if (!session.data?.user.id) return; setOwnId(session.data?.user.id); }, [session.data?.user.id]); @@ -47,7 +47,7 @@ export const Chat = () => { const filteredAircrafts = aircrafts?.filter((a) => a.userId !== session.data?.user.id); return ( -
+
{Object.values(chats).some((c) => c.notification) && ( @@ -68,9 +68,9 @@ export const Chat = () => { {chatOpen && (
-
+

Chat

@@ -118,7 +118,7 @@ export const Chat = () => { +
-
+
{Object.keys(chats).map((userId) => { const chat = chats[userId]; if (!chat) return null; @@ -126,7 +126,6 @@ export const Chat = () => { `} checked={selectedChat === userId} @@ -140,7 +139,7 @@ export const Chat = () => { } }} /> -
+
{chat.messages.map((chatMessage) => { const isSender = chatMessage.senderId === session.data?.user.id; return ( @@ -173,6 +172,22 @@ export const Chat = () => { onChange={(e) => { setMessage(e.target.value); }} + onKeyDown={(e) => { + if (e.key === "Enter" && !e.shiftKey) { + e.preventDefault(); + if (message.length < 1) return; + if (!selectedChat) return; + setSending(true); + sendMessage(selectedChat, message) + .then(() => { + setMessage(""); + setSending(false); + }) + .catch(() => { + setSending(false); + }); + } + }} value={message} /> diff --git a/apps/dispatch/app/_components/left/Report.tsx b/apps/dispatch/app/_components/left/Report.tsx index d839447d..795a7831 100644 --- a/apps/dispatch/app/_components/left/Report.tsx +++ b/apps/dispatch/app/_components/left/Report.tsx @@ -38,7 +38,9 @@ export const Report = () => { const filteredAircrafts = aircrafts?.filter((a) => a.userId !== session.data?.user.id); return ( -
+
    {missionStations?.map((station, index) => { - const connectedAircraft = conenctedAircrafts?.find( + const connectedAircraft = connectedAircrafts?.find( (aircraft) => aircraft.stationId === station.id, ); @@ -550,15 +527,15 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {