From ea4144ccc79edd96806d635a479adcf788f83fd3 Mon Sep 17 00:00:00 2001 From: Timo K Date: Thu, 28 May 2026 12:04:42 +0200 Subject: [PATCH] Fix play of second leave sound --- src/room/GroupCallView.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index 95b77e73..009ac3a6 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -318,12 +318,24 @@ export const GroupCallView: FC = ({ ( reason: "timeout" | "user" | "allOthersLeft" | "decline" | "error", ): void => { - let playSound: CallEventSounds = "left"; - if (reason === "timeout" || reason === "decline") playSound = reason; + let audioPromise: Promise | undefined = undefined; + switch (reason) { + case "allOthersLeft": + // When "allOthersLeft", the leaveSoundEffect$ in CallEventAudioRenderer + // already plays the "left" sound when the remote participant's media + // disappears. Playing it here too would cause the sound to play twice. + break; + case "timeout": + case "decline": + audioPromise = leaveSoundContext.current?.playSound(reason); + break; + default: + audioPromise = leaveSoundContext.current?.playSound("left"); + } setJoined(false); setLeft(true); - const audioPromise = leaveSoundContext.current?.playSound(playSound); + // We need to wait until the callEnded event is tracked on PostHog, // otherwise the iframe may get killed first. const posthogRequest = new Promise((resolve) => {