Provides correct behavior when call isn't active and no activeClientWidgetApi exists yet

This commit is contained in:
Gigiaj 2025-05-23 13:21:40 -05:00
parent b6afe3b968
commit 03cbecc3f9

View file

@ -243,17 +243,24 @@ export function CallProvider({ children }: CallProviderProps) {
setIsCallActive(true); setIsCallActive(true);
return; return;
} }
if (activeClientWidgetApi) {
if (isCallActive && activeClientWidgetApi && viewedClientWidgetApi) { if (isCallActive && viewedClientWidgetApi) {
activeClientWidgetApi?.removeAllListeners(); activeClientWidgetApi?.removeAllListeners();
activeClientWidgetApi?.transport.send(WIDGET_HANGUP_ACTION, {}).then(() => { activeClientWidgetApi?.transport.send(WIDGET_HANGUP_ACTION, {}).then(() => {
setActiveClientWidgetApi(viewedClientWidgetApi, viewedCallRoomId); setActiveClientWidgetApi(viewedClientWidgetApi, viewedCallRoomId);
setActiveCallRoomIdState(viewedCallRoomId); setActiveCallRoomIdState(viewedCallRoomId);
setViewedClientWidgetApi(null, null); setViewedClientWidgetApi(null, null);
setIsPrimaryIframe(!isPrimaryIframe); setIsPrimaryIframe(!isPrimaryIframe);
setIsCallActive(true);
});
} else {
setIsCallActive(true); setIsCallActive(true);
}); }
} else { } else {
setIsPrimaryIframe(!isPrimaryIframe);
setActiveClientWidgetApi(viewedClientWidgetApi, viewedCallRoomId);
setActiveCallRoomIdState(viewedCallRoomId);
setViewedClientWidgetApi(null, null);
setIsCallActive(true); setIsCallActive(true);
} }
}; };