From 8b0f5054ddd7d9446db24dcad432310306e4273d Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 18 Jun 2026 09:13:19 +0200 Subject: [PATCH] Revert to original fix for duplicate leave sounds My attempted simpler fix of applying takeUntil(autoLeave$) to leaveSoundEffect$ didn't work. --- src/room/GroupCallView.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index f5e1be5eb..09ea15be3 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -338,12 +338,25 @@ 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. We play it here silenced (volumeOverwrite = 0) so we have the right duration in the audioPromise. + // (used to destory the widget) + audioPromise = leaveSoundContext.current?.playSound("left", 0); + 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.