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)

This commit is contained in:
Gigiaj 2025-05-24 19:34:26 -05:00
parent f2f98a6973
commit 0ef9c56a25

View file

@ -36,7 +36,9 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro
isCallActive, isCallActive,
isPrimaryIframe, isPrimaryIframe,
registerActiveClientWidgetApi, registerActiveClientWidgetApi,
activeClientWidget,
registerViewedClientWidgetApi, registerViewedClientWidgetApi,
viewedClientWidget,
} = useCallState(); } = useCallState();
const mx = useMatrixClient(); const mx = useMatrixClient();
const clientConfig = useClientConfig(); const clientConfig = useClientConfig();
@ -63,12 +65,6 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro
(!activeCallRoomId && viewedCallRoomId && !isCallActive) (!activeCallRoomId && viewedCallRoomId && !isCallActive)
) { ) {
const roomIdToSet = (skipLobby ? activeCallRoomId : viewedCallRoomId) ?? ''; const roomIdToSet = (skipLobby ? activeCallRoomId : viewedCallRoomId) ?? '';
if (
roomIdToSet &&
(roomIdToSet === primarySmallWidgetRef?.current?.roomId ||
roomIdToSet === backupSmallWidgetRef?.current?.roomId)
)
return;
const widgetId = `element-call-${roomIdToSet}-${Date.now()}`; const widgetId = `element-call-${roomIdToSet}-${Date.now()}`;
const newUrl = getWidgetUrl( const newUrl = getWidgetUrl(
@ -84,10 +80,18 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro
); );
if ( if (
newUrl.toString() === primarySmallWidgetRef?.current?.url || (primarySmallWidgetRef.current?.roomId || backupSmallWidgetRef.current?.roomId) &&
newUrl.toString() === backupSmallWidgetRef?.current?.url (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; return;
}
if (iframeRef.current && iframeRef.current.src !== newUrl.toString()) { if (iframeRef.current && iframeRef.current.src !== newUrl.toString()) {
iframeRef.current.src = newUrl.toString(); iframeRef.current.src = newUrl.toString();
@ -119,9 +123,9 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro
const widgetApiInstance = smallWidget.startMessaging(iframeElement); const widgetApiInstance = smallWidget.startMessaging(iframeElement);
widgetApiRef.current = widgetApiInstance; widgetApiRef.current = widgetApiInstance;
if (skipLobby) { if (skipLobby) {
registerActiveClientWidgetApi(activeCallRoomId, widgetApiRef.current); registerActiveClientWidgetApi(activeCallRoomId, widgetApiRef.current, smallWidget);
} else { } else {
registerViewedClientWidgetApi(viewedCallRoomId, widgetApiRef.current); registerViewedClientWidgetApi(viewedCallRoomId, widgetApiRef.current, smallWidget);
} }
widgetApiInstance.once('ready', () => { widgetApiInstance.once('ready', () => {
@ -131,11 +135,14 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro
} }
}, },
[ [
activeCallRoomId,
mx, mx,
activeCallRoomId,
viewedCallRoomId, viewedCallRoomId,
isCallActive, isCallActive,
clientConfig.elementCallUrl, clientConfig.elementCallUrl,
viewedClientWidget,
activeClientWidget,
viewedRoomId,
registerActiveClientWidgetApi, registerActiveClientWidgetApi,
registerViewedClientWidgetApi, registerViewedClientWidgetApi,
] ]