in packages/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.ts [278:346]
public updateClientState(clientState: CallClientState): void {
let call = this.callId ? clientState.calls[this.callId] : undefined;
const latestEndedCall = clientState.callsEnded ? findLatestEndedCall(clientState.callsEnded) : undefined;
// As the state is transitioning to a new state, trigger appropriate callback events.
const oldPage = this.state.page;
/* @conditional-compile-remove(unsupported-browser) */
const environmentInfo = {
environmentInfo: this.state.environmentInfo,
unsupportedBrowserVersionOptedIn: this.state.unsupportedBrowserVersionsAllowed
};
const latestAcceptedTransfer = call?.transfer.acceptedTransfers
? findLatestAcceptedTransfer(call.transfer.acceptedTransfers)
: undefined;
const transferCall = latestAcceptedTransfer ? clientState.calls[latestAcceptedTransfer.callId] : undefined;
if (call?.state === 'Connected' || call?.state === 'Connecting') {
this.setIsReturningFromBreakoutRoom(false);
}
let isReturningFromBreakoutRoom = false;
isReturningFromBreakoutRoom = this.isReturningFromBreakoutRoom;
const newPage = getCallCompositePage(
call,
latestEndedCall,
transferCall,
isReturningFromBreakoutRoom,
/* @conditional-compile-remove(unsupported-browser) */ environmentInfo
);
if (!IsCallEndedPage(oldPage) && IsCallEndedPage(newPage)) {
/**
* We want to make sure that the id of the call that is ending
* is the same as the call in the adapter as this is a scenario where
* the call has ended and not been transferred and report the codes for this call.
*/
if (this.callId === latestEndedCall?.id) {
this.emitter.emit('callEnded', {
callId: latestEndedCall?.id,
code: latestEndedCall?.callEndReason?.code,
subCode: latestEndedCall?.callEndReason?.subCode
});
}
// Reset the callId to undefined as the call has ended.
this.setCurrentCallId(undefined);
// Make sure that the call is set to undefined in the state.
call = undefined;
}
if (this.state.page) {
this.setState({
...this.state,
userId: clientState.userId,
displayName: clientState.callAgent?.displayName,
call,
page: newPage,
endedCall: latestEndedCall,
devices: clientState.deviceManager,
latestErrors: clientState.latestErrors,
latestNotifications: clientState.latestNotifications,
cameraStatus:
call?.localVideoStreams.find((s) => s.mediaStreamType === 'Video') ||
clientState.deviceManager.unparentedViews.find((s) => s.mediaStreamType === 'Video')
? 'On'
: 'Off',
acceptedTransferCallState: transferCall
});
}
}