mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-06 07:20:29 +03:00
Conditionals to manage the active iframe state better
This commit is contained in:
parent
6601c47abc
commit
f28a3a1c7d
1 changed files with 26 additions and 7 deletions
|
|
@ -55,8 +55,9 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro
|
||||||
const setupWidget = useCallback(
|
const setupWidget = useCallback(
|
||||||
(widgetApiRef, smallWidgetRef, iframeRef, skipLobby) => {
|
(widgetApiRef, smallWidgetRef, iframeRef, skipLobby) => {
|
||||||
const cleanupRoomId = smallWidgetRef.current?.roomId;
|
const cleanupRoomId = smallWidgetRef.current?.roomId;
|
||||||
logger.debug(`PersistentCallContainer effect running. activeCallRoomId: ${activeCallRoomId}`);
|
logger.error(`PersistentCallContainer effect running. activeCallRoomId: ${activeCallRoomId}`);
|
||||||
|
logger.error(`PersistentCallContainer effect running. viewedCallRoomId: ${viewedCallRoomId}`);
|
||||||
|
logger.error(`PersistentCallContainer effect running. isCallActive: ${isCallActive}`);
|
||||||
/**
|
/**
|
||||||
* TODO:
|
* TODO:
|
||||||
* Need proper shutdown handling. Events from the previous widget can still come through it seems. Might need
|
* Need proper shutdown handling. Events from the previous widget can still come through it seems. Might need
|
||||||
|
|
@ -82,12 +83,20 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro
|
||||||
|
|
||||||
if (mx?.getUserId()) {
|
if (mx?.getUserId()) {
|
||||||
if (
|
if (
|
||||||
(isCallActive && activeCallRoomId !== viewedCallRoomId) ||
|
(activeCallRoomId !== viewedCallRoomId && isCallActive) ||
|
||||||
// && backupIframeRef.current && primaryIframeRef.current.src
|
// &&
|
||||||
(cleanupRoomId !== activeCallRoomId && !isCallActive)
|
(activeCallRoomId && cleanupRoomId !== activeCallRoomId && !isCallActive)
|
||||||
) {
|
) {
|
||||||
//logger.error('PersistentCallContainer Re-render');
|
logger.error('PersistentCallContainer Re-render');
|
||||||
const roomIdToSet = skipLobby ? activeCallRoomId : viewedCallRoomId;
|
const roomIdToSet = skipLobby ? activeCallRoomId : viewedCallRoomId;
|
||||||
|
|
||||||
|
if (
|
||||||
|
roomIdToSet &&
|
||||||
|
(roomIdToSet === primarySmallWidgetRef?.current?.roomId ||
|
||||||
|
roomIdToSet === backupSmallWidgetRef?.current?.roomId)
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
const newUrl = getWidgetUrl(mx, roomIdToSet, clientConfig.elementCallUrl ?? '', {
|
const newUrl = getWidgetUrl(mx, roomIdToSet, clientConfig.elementCallUrl ?? '', {
|
||||||
skipLobby: skipLobby.toString(),
|
skipLobby: skipLobby.toString(),
|
||||||
returnToLobby: 'true',
|
returnToLobby: 'true',
|
||||||
|
|
@ -105,7 +114,17 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro
|
||||||
);
|
);
|
||||||
iframeRef.current.src = newUrl.toString();
|
iframeRef.current.src = newUrl.toString();
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
newUrl.toString() === primarySmallWidgetRef?.current?.url ||
|
||||||
|
newUrl.toString() === backupSmallWidgetRef?.current?.url
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
logger.error(
|
||||||
|
`New: ${roomIdToSet}
|
||||||
|
\n Primary: ${primarySmallWidgetRef?.current?.roomId}
|
||||||
|
\n Backup: ${backupSmallWidgetRef?.current?.roomId}`
|
||||||
|
);
|
||||||
const iframeElement = iframeRef.current;
|
const iframeElement = iframeRef.current;
|
||||||
if (!iframeElement) {
|
if (!iframeElement) {
|
||||||
logger.error('PersistentCallContainer: iframeRef is null, cannot setup API.');
|
logger.error('PersistentCallContainer: iframeRef is null, cannot setup API.');
|
||||||
|
|
@ -120,7 +139,7 @@ export function PersistentCallContainer({ children }: PersistentCallContainerPro
|
||||||
'Element Call',
|
'Element Call',
|
||||||
'm.call',
|
'm.call',
|
||||||
newUrl,
|
newUrl,
|
||||||
true,
|
false,
|
||||||
getWidgetData(mx, roomIdToSet, {}, { skipLobby: true }),
|
getWidgetData(mx, roomIdToSet, {}, { skipLobby: true }),
|
||||||
roomIdToSet
|
roomIdToSet
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue