mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-06 15:30:27 +03:00
Testing the iframe juggling. Seems to work for the first and second joins... so likely on the right path with this
This commit is contained in:
parent
5ab0b39152
commit
f3612e23c6
1 changed files with 54 additions and 22 deletions
|
|
@ -132,8 +132,9 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||||
const hangUp = useCallback(() => {
|
const hangUp = useCallback(() => {
|
||||||
logger.debug(`CallContext: Hang up called.`);
|
logger.debug(`CallContext: Hang up called.`);
|
||||||
activeClientWidgetApi?.transport.send(`${WIDGET_HANGUP_ACTION}`, {});
|
activeClientWidgetApi?.transport.send(`${WIDGET_HANGUP_ACTION}`, {});
|
||||||
setIsCallActive(false);
|
//setActiveCallRoomIdState(null);
|
||||||
}, [activeClientWidgetApi]);
|
//setIsCallActive(false);
|
||||||
|
}, [activeClientWidgetApi?.transport]);
|
||||||
|
|
||||||
const setActiveClientWidgetApi = useCallback(
|
const setActiveClientWidgetApi = useCallback(
|
||||||
(clientWidgetApi: ClientWidgetApi | null, roomId: string | null) => {
|
(clientWidgetApi: ClientWidgetApi | null, roomId: string | null) => {
|
||||||
|
|
@ -182,11 +183,11 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roomId && clientWidgetApi) {
|
if (roomId && clientWidgetApi) {
|
||||||
logger.error(`CallContext: Registering active clientWidgetApi for room ${roomId}.`);
|
logger.error(`CallContext: Registering viewed clientWidgetApi for room ${roomId}.`);
|
||||||
setViewedClientWidgetApi(clientWidgetApi, roomId);
|
setViewedClientWidgetApi(clientWidgetApi, roomId);
|
||||||
} else if (roomId === viewedClientWidgetApiRoomId || roomId === null) {
|
} else if (roomId === viewedClientWidgetApiRoomId || roomId === null) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`CallContext: Clearing active clientWidgetApi for room ${viewedClientWidgetApiRoomId}.`
|
`CallContext: Clearing viewed clientWidgetApi for room ${viewedClientWidgetApiRoomId}.`
|
||||||
);
|
);
|
||||||
setViewedClientWidgetApi(null, null);
|
setViewedClientWidgetApi(null, null);
|
||||||
//resetMediaState();
|
//resetMediaState();
|
||||||
|
|
@ -200,19 +201,13 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (!activeCallRoomId || !viewedCallRoomId) {
|
||||||
!activeClientWidgetApi ||
|
|
||||||
!viewedClientWidgetApi ||
|
|
||||||
!activeCallRoomId ||
|
|
||||||
!viewedCallRoomId ||
|
|
||||||
isCallActive
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//logger.error(viewedClientWidgetApi);
|
//logger.error(viewedClientWidgetApi);
|
||||||
const handleHangup = (ev: CustomEvent) => {
|
const handleHangup = (ev: CustomEvent) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
hangUp();
|
//hangUp();
|
||||||
// if (!isPrimaryIframe) {
|
// if (!isPrimaryIframe) {
|
||||||
activeClientWidgetApi?.transport.reply(ev.detail, {});
|
activeClientWidgetApi?.transport.reply(ev.detail, {});
|
||||||
// } else {
|
// } else {
|
||||||
|
|
@ -223,7 +218,7 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||||
ev
|
ev
|
||||||
);
|
);
|
||||||
//setIsPrimaryIframe(!isPrimaryIframe);
|
//setIsPrimaryIframe(!isPrimaryIframe);
|
||||||
setIsCallActive(false);
|
//setIsCallActive(false);
|
||||||
//setActiveCallRoomIdState(null);
|
//setActiveCallRoomIdState(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -255,16 +250,53 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||||
|
|
||||||
const handleJoin = (ev: CustomEvent) => {
|
const handleJoin = (ev: CustomEvent) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
if (isCallActive && activeClientWidgetApi) {
|
|
||||||
activeClientWidgetApi?.transport.send(WIDGET_HANGUP_ACTION, {}).then(() => {
|
logger.error('PRE Swap');
|
||||||
setActiveCallRoomIdState(viewedCallRoomId);
|
logger.error('PRE Swap');
|
||||||
setActiveClientWidgetApi(viewedClientWidgetApi, viewedCallRoomId);
|
logger.error('PRE Swap');
|
||||||
//setIsPrimaryIframe(!isPrimaryIframe);
|
logger.error('PRE Swap');
|
||||||
//setViewedClientWidgetApi(null, null);
|
logger.error('PRE Swap');
|
||||||
setIsCallActive(true);
|
logger.error('PRE Swap');
|
||||||
activeClientWidgetApi?.transport.reply(ev.detail, {});
|
logger.error('PRE Swap');
|
||||||
});
|
logger.error('PRE Swap');
|
||||||
|
logger.error('PRE Swap');
|
||||||
|
logger.error('PRE Swap');
|
||||||
|
logger.error('PRE Swap');
|
||||||
|
logger.error('PRE Swap');
|
||||||
|
logger.error('PRE Swap');
|
||||||
|
logger.error(isCallActive.toString());
|
||||||
|
logger.error(activeClientWidgetApi);
|
||||||
|
logger.error(viewedClientWidgetApi);
|
||||||
|
|
||||||
|
activeClientWidgetApi?.transport.reply(ev.detail, {});
|
||||||
|
if (isCallActive && activeClientWidgetApi && viewedClientWidgetApi) {
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
logger.error('Primary Swap');
|
||||||
|
activeClientWidgetApi?.transport.send(WIDGET_HANGUP_ACTION, {}).then(() => {});
|
||||||
|
|
||||||
|
setActiveCallRoomIdState(viewedCallRoomId);
|
||||||
|
setActiveClientWidgetApi(viewedClientWidgetApi, viewedCallRoomId);
|
||||||
|
setIsPrimaryIframe(!isPrimaryIframe);
|
||||||
|
//setViewedCallRoomId(null);
|
||||||
|
//setViewedClientWidgetApi(null, null);
|
||||||
|
//setViewedClientWidgetApi(null, null);
|
||||||
|
} else {
|
||||||
|
//setActiveCallRoomIdState(viewedCallRoomId);
|
||||||
}
|
}
|
||||||
|
setIsCallActive(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue