mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-06 07:20:29 +03:00
Much closer to the call state handling we want w/ hangups and joins
This commit is contained in:
parent
59a936b094
commit
74c883dfa8
1 changed files with 4 additions and 49 deletions
|
|
@ -96,7 +96,6 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||||
logger.debug('CallContext: Resetting media state to defaults.');
|
logger.debug('CallContext: Resetting media state to defaults.');
|
||||||
setIsAudioEnabledState(DEFAULT_AUDIO_ENABLED);
|
setIsAudioEnabledState(DEFAULT_AUDIO_ENABLED);
|
||||||
setIsVideoEnabledState(DEFAULT_VIDEO_ENABLED);
|
setIsVideoEnabledState(DEFAULT_VIDEO_ENABLED);
|
||||||
//setIsChatOpenState(DEFAULT_CHAT_OPENED);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const setActiveCallRoomId = useCallback(
|
const setActiveCallRoomId = useCallback(
|
||||||
|
|
@ -114,8 +113,6 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`CallContext: Clearing active clientWidgetApi because active room changed to ${roomId} or was cleared.`
|
`CallContext: Clearing active clientWidgetApi because active room changed to ${roomId} or was cleared.`
|
||||||
);
|
);
|
||||||
//setActiveClientWidgetApiState(null);
|
|
||||||
//setActiveClientWidgetApiRoomId(null);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[activeClientWidgetApiRoomId, resetMediaState, activeCallRoomId]
|
[activeClientWidgetApiRoomId, resetMediaState, activeCallRoomId]
|
||||||
|
|
@ -132,8 +129,8 @@ 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}`, {});
|
||||||
//setActiveCallRoomIdState(null);
|
setActiveCallRoomIdState(null);
|
||||||
//setIsCallActive(false);
|
setIsCallActive(false);
|
||||||
}, [activeClientWidgetApi?.transport]);
|
}, [activeClientWidgetApi?.transport]);
|
||||||
|
|
||||||
const setActiveClientWidgetApi = useCallback(
|
const setActiveClientWidgetApi = useCallback(
|
||||||
|
|
@ -171,7 +168,7 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||||
const setViewedClientWidgetApi = useCallback(
|
const setViewedClientWidgetApi = useCallback(
|
||||||
(clientWidgetApi: ClientWidgetApi | null, roomId: string | null) => {
|
(clientWidgetApi: ClientWidgetApi | null, roomId: string | null) => {
|
||||||
setViewedClientWidgetApiState(clientWidgetApi);
|
setViewedClientWidgetApiState(clientWidgetApi);
|
||||||
//setViewedClientWidgetApiRoomId(roomId);
|
setViewedClientWidgetApiRoomId(roomId);
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
@ -204,22 +201,15 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||||
if (!activeCallRoomId || !viewedCallRoomId) {
|
if (!activeCallRoomId || !viewedCallRoomId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//logger.error(viewedClientWidgetApi);
|
|
||||||
const handleHangup = (ev: CustomEvent) => {
|
const handleHangup = (ev: CustomEvent) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
//hangUp();
|
|
||||||
// if (!isPrimaryIframe) {
|
|
||||||
activeClientWidgetApi?.transport.reply(ev.detail, {});
|
activeClientWidgetApi?.transport.reply(ev.detail, {});
|
||||||
// } else {
|
|
||||||
viewedClientWidgetApi?.transport.reply(ev.detail, {});
|
viewedClientWidgetApi?.transport.reply(ev.detail, {});
|
||||||
// }
|
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`CallContext: Received hangup action from widget in room ${activeCallRoomId}.`,
|
`CallContext: Received hangup action from widget in room ${activeCallRoomId}.`,
|
||||||
ev
|
ev
|
||||||
);
|
);
|
||||||
//setIsPrimaryIframe(!isPrimaryIframe);
|
setIsCallActive(false);
|
||||||
//setIsCallActive(false);
|
|
||||||
//setActiveCallRoomIdState(null);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMediaStateUpdate = (ev: CustomEvent<MediaStatePayload>) => {
|
const handleMediaStateUpdate = (ev: CustomEvent<MediaStatePayload>) => {
|
||||||
|
|
@ -250,51 +240,16 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||||
|
|
||||||
const handleJoin = (ev: CustomEvent) => {
|
const handleJoin = (ev: CustomEvent) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
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('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(isCallActive.toString());
|
||||||
logger.error(activeClientWidgetApi);
|
logger.error(activeClientWidgetApi);
|
||||||
logger.error(viewedClientWidgetApi);
|
logger.error(viewedClientWidgetApi);
|
||||||
|
|
||||||
activeClientWidgetApi?.transport.reply(ev.detail, {});
|
activeClientWidgetApi?.transport.reply(ev.detail, {});
|
||||||
if (isCallActive && activeClientWidgetApi && viewedClientWidgetApi) {
|
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(() => {});
|
activeClientWidgetApi?.transport.send(WIDGET_HANGUP_ACTION, {}).then(() => {});
|
||||||
|
|
||||||
setActiveCallRoomIdState(viewedCallRoomId);
|
setActiveCallRoomIdState(viewedCallRoomId);
|
||||||
setActiveClientWidgetApi(viewedClientWidgetApi, viewedCallRoomId);
|
setActiveClientWidgetApi(viewedClientWidgetApi, viewedCallRoomId);
|
||||||
setIsPrimaryIframe(!isPrimaryIframe);
|
setIsPrimaryIframe(!isPrimaryIframe);
|
||||||
//setViewedCallRoomId(null);
|
|
||||||
//setViewedClientWidgetApi(null, null);
|
|
||||||
//setViewedClientWidgetApi(null, null);
|
|
||||||
} else {
|
|
||||||
//setActiveCallRoomIdState(viewedCallRoomId);
|
|
||||||
}
|
}
|
||||||
setIsCallActive(true);
|
setIsCallActive(true);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue