From 0ef9c56a253ad50ceec97da94d46078c56f2e04d Mon Sep 17 00:00:00 2001 From: Gigiaj Date: Sat, 24 May 2025 19:34:26 -0500 Subject: [PATCH] Update rendering logic to clear up remaining rendering bug (straight to call -> lobby of another room and joining call from that interface -> lobby of that previous room and joining was leading to duplication of the user in lobbies. This was actually from listening to and acknowledging hangups from the viewed widget in CallProvider) --- .../client/call/PersistentCallContainer.tsx | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/app/pages/client/call/PersistentCallContainer.tsx b/src/app/pages/client/call/PersistentCallContainer.tsx index e6258464..3e44df3e 100644 --- a/src/app/pages/client/call/PersistentCallContainer.tsx +++ b/src/app/pages/client/call/PersistentCallContainer.tsx @@ -36,7 +36,9 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro isCallActive, isPrimaryIframe, registerActiveClientWidgetApi, + activeClientWidget, registerViewedClientWidgetApi, + viewedClientWidget, } = useCallState(); const mx = useMatrixClient(); const clientConfig = useClientConfig(); @@ -63,12 +65,6 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro (!activeCallRoomId && viewedCallRoomId && !isCallActive) ) { const roomIdToSet = (skipLobby ? activeCallRoomId : viewedCallRoomId) ?? ''; - if ( - roomIdToSet && - (roomIdToSet === primarySmallWidgetRef?.current?.roomId || - roomIdToSet === backupSmallWidgetRef?.current?.roomId) - ) - return; const widgetId = `element-call-${roomIdToSet}-${Date.now()}`; const newUrl = getWidgetUrl( @@ -84,10 +80,18 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro ); if ( - newUrl.toString() === primarySmallWidgetRef?.current?.url || - newUrl.toString() === backupSmallWidgetRef?.current?.url - ) + (primarySmallWidgetRef.current?.roomId || backupSmallWidgetRef.current?.roomId) && + (skipLobby + ? activeClientWidget?.roomId && + (activeClientWidget.roomId === primarySmallWidgetRef.current?.roomId || + activeClientWidget.roomId === backupSmallWidgetRef.current?.roomId) + : viewedClientWidget?.roomId && + viewedRoomId === viewedClientWidget.roomId && + (viewedClientWidget.roomId === primarySmallWidgetRef.current?.roomId || + viewedClientWidget.roomId === backupSmallWidgetRef.current?.roomId)) + ) { return; + } if (iframeRef.current && iframeRef.current.src !== newUrl.toString()) { iframeRef.current.src = newUrl.toString(); @@ -119,9 +123,9 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro const widgetApiInstance = smallWidget.startMessaging(iframeElement); widgetApiRef.current = widgetApiInstance; if (skipLobby) { - registerActiveClientWidgetApi(activeCallRoomId, widgetApiRef.current); + registerActiveClientWidgetApi(activeCallRoomId, widgetApiRef.current, smallWidget); } else { - registerViewedClientWidgetApi(viewedCallRoomId, widgetApiRef.current); + registerViewedClientWidgetApi(viewedCallRoomId, widgetApiRef.current, smallWidget); } widgetApiInstance.once('ready', () => { @@ -131,11 +135,14 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro } }, [ - activeCallRoomId, mx, + activeCallRoomId, viewedCallRoomId, isCallActive, clientConfig.elementCallUrl, + viewedClientWidget, + activeClientWidget, + viewedRoomId, registerActiveClientWidgetApi, registerViewedClientWidgetApi, ]