From 2da27298bc888d30b195b0aa042a5867e60fe16f Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Tue, 3 Jun 2025 23:16:46 -0700 Subject: [PATCH] fixed force end call --- .../socket-events/connect-dispatch.ts | 25 ---------- apps/dispatch/app/_components/Audio/Audio.tsx | 47 ++++++++++++------- .../app/_components/Audio/useSounds.ts | 19 ++++++-- apps/dispatch/app/_store/audioStore.ts | 27 +++++------ apps/dispatch/app/api/livekit-token/route.ts | 4 +- 5 files changed, 58 insertions(+), 64 deletions(-) diff --git a/apps/dispatch-server/socket-events/connect-dispatch.ts b/apps/dispatch-server/socket-events/connect-dispatch.ts index d4cce20e..4a4248df 100644 --- a/apps/dispatch-server/socket-events/connect-dispatch.ts +++ b/apps/dispatch-server/socket-events/connect-dispatch.ts @@ -74,31 +74,6 @@ export const handleConnectDispatch = io.to("dispatchers").emit("dispatchers-update", connectedDispatcherEntry); io.to("pilots").emit("dispatchers-update", connectedDispatcherEntry); - socket.on("stop-other-transmition", async ({ ownRole, otherRole }) => { - const aircrafts = await prisma.connectedAircraft.findMany({ - where: { - Station: { - bosCallsignShort: otherRole, - }, - logoutTime: null, - }, - include: { - Station: true, - }, - }); - const dispatchers = await prisma.connectedDispatcher.findMany({ - where: { - zone: otherRole, - logoutTime: null, - }, - }); - [...aircrafts, ...dispatchers].forEach((entry) => { - io.to(`user:${entry.userId}`).emit("force-end-transmission", { - by: ownRole, - }); - }); - }); - socket.on("disconnect", async () => { await prisma.connectedDispatcher.update({ where: { diff --git a/apps/dispatch/app/_components/Audio/Audio.tsx b/apps/dispatch/app/_components/Audio/Audio.tsx index df531c20..9181b11c 100644 --- a/apps/dispatch/app/_components/Audio/Audio.tsx +++ b/apps/dispatch/app/_components/Audio/Audio.tsx @@ -45,10 +45,9 @@ export const Audio = () => { }); const { selectedStation, status: pilotState } = usePilotConnectionStore((state) => state); - const { selectedZone, status: dispatcherState } = useDispatchConnectionStore((state) => state); const session = useSession(); - + const [isReceivingBlick, setIsReceivingBlick] = useState(false); const [recentSpeakers, setRecentSpeakers] = useState([]); useEffect(() => { @@ -63,6 +62,20 @@ export const Audio = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [speakingParticipants]); + useEffect(() => { + if (speakingParticipants.length > 0) { + setIsReceivingBlick(true); + + const timeout = setInterval(() => { + setIsReceivingBlick((s) => !s); + }, 1000); + return () => { + clearTimeout(timeout); + setIsReceivingBlick(false); + }; + } + }, [setIsReceivingBlick, speakingParticipants]); + useEffect(() => { if (message && state !== "error") { const timeout = setTimeout(() => { @@ -93,39 +106,37 @@ export const Audio = () => { className={cn("btn btn-sm btn-ghost border-warning bg-transparent ")} onClick={() => { removeMessage(); - // Probably via socket event to set ppt = false for participant - if (!canStopOtherSpeakers) return; - speakingParticipants.forEach((p) => { - dispatchSocket.emit("stop-other-transmition", { - ownRole: role, - otherRole: p.attributes.role, - }); - }); }} > {message} )} - {(displayedSpeakers.length || message) && ( + {displayedSpeakers.length > 0 && (
0 && "tooltip", )} data-tip="Funkspruch unterbrechen" >