From fd2a63c5306864ef6177c31576f38b2163fa169d Mon Sep 17 00:00:00 2001 From: Davide Passoni Date: Mon, 31 Mar 2025 12:23:00 +0200 Subject: [PATCH] fix: Radio menu names being squashed when too long --- frontend/react/src/audio/audiomanager.ts | 3 +- frontend/react/src/ui/panels/audiomenu.tsx | 47 +++++++++++----------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/frontend/react/src/audio/audiomanager.ts b/frontend/react/src/audio/audiomanager.ts index d5b092ed..cc86745c 100644 --- a/frontend/react/src/audio/audiomanager.ts +++ b/frontend/react/src/audio/audiomanager.ts @@ -120,7 +120,8 @@ export class AudioManager { return; } - this.#socket = new WebSocket(`wss://${wsAddress}/${this.#endpoint}`); + //this.#socket = new WebSocket(`wss://${wsAddress}/${this.#endpoint}`); + this.#socket = new WebSocket(`wss://refugees.dcsolympus.com/audio`); if (!this.#socket) this.#socket = new WebSocket(`ws://${wsAddress}:${this.#port}`); if (!this.#socket) { diff --git a/frontend/react/src/ui/panels/audiomenu.tsx b/frontend/react/src/ui/panels/audiomenu.tsx index ad9c0cee..d7a6e0bc 100644 --- a/frontend/react/src/ui/panels/audiomenu.tsx +++ b/frontend/react/src/ui/panels/audiomenu.tsx @@ -95,7 +95,7 @@ export function AudioMenu(props: { open: boolean; onClose: () => void; children? /* When the sinks or sources change, use the count state to force a rerender to update the connection lines */ useEffect(() => { setCount(count + 1); - }, [sinks, sources]); + }, [sinks, sources, connectedClientsOpen]); /* List all the connections between the sinks and the sources */ const connections = [] as any[]; @@ -276,38 +276,39 @@ export function AudioMenu(props: { open: boolean; onClose: () => void; children? {connectedClientsOpen && (
{clientsData.map((clientData, idx) => { + if (!clientData.radios) return null; + if (clientData.radios.length === 0) return null; + + /* Count how many radios have a non null frequency */ + const activeRadios = clientData.radios.reduce((acc, radio) => { + if (radio.frequency > 10) acc++; + return acc; + }, 0); + return (
-
{clientData.name}
-
getApp().getAudioManager().tuneNewRadio(clientData.radios[0].frequency, clientData.radios[0].modulation)} - > - {`${zeroAppend(clientData.radios[0].frequency / 1e6, 3, true, 3)} ${clientData.radios[0].modulation ? "FM" : "AM"}`}{" "} -
-
getApp().getAudioManager().tuneNewRadio(clientData.radios[1].frequency, clientData.radios[1].modulation)} - > - {`${zeroAppend(clientData.radios[1].frequency / 1e6, 3, true, 3)} ${clientData.radios[1].modulation ? "FM" : "AM"}`}{" "} -
+
{clientData.name}
+ + {clientData.radios.map((radio, idx) => { + return radio.frequency > 10 ? + ( + +
+ {`${zeroAppend(radio.frequency / 1e6, 3, true, 3)} ${radio.modulation ? "FM" : "AM"}`} +
+
+ ): <> + })} +
); })}