import { CommunicationIdentifierKind } from '@azure/communication-common' ; import { CallAdapter , CallAdapterClientState , CallAdapterState , CallAdapterUiState } from '../../CallComposite' ; import { ChatAdapter , ChatAdapterState } from '../../ChatComposite' ; import { callPageToMeetingPage , MeetingCompositePage } from './MeetingCompositePage' ; import { meetingStateFromBackingStates , MeetingState , mergeCallStateIntoMeetingState , mergeChatStateIntoMeetingState } from './MeetingState' ; beta export interface MeetingAdapterUiState extends Pick < CallAdapterUiState , 'isLocalPreviewMicrophoneEnabled' > { /** Current page in the meeting composite. */ page : MeetingCompositePage ; } beta export interface MeetingAdapterClientState extends Pick < CallAdapterClientState , 'devices' | 'isTeamsCall' > { /** ID of the meeting participant using this Meeting Adapter. */ userId : CommunicationIdentifierKind ; /** Display name of the meeting participant using this Meeting Adapter. */ displayName : string | undefined ; /** State of the current Meeting. */ meeting : MeetingState | undefined ; } beta export interface MeetingAdapterState extends MeetingAdapterUiState , MeetingAdapterClientState { } private export function meetingAdapterStateFromBackingStates ( callAdapter , chatAdapter ) { const callAdapterState = callAdapter . getState ( ) ; const chatAdapterState = chatAdapter . getState ( ) ; const meeting = callAdapterState . call ? meetingStateFromBackingStates ( callAdapterState . call , chatAdapterState . thread ) : undefined ; return { meeting , userId : callAdapterState . userId , page : callPageToMeetingPage ( callAdapterState . page ) , displayName : callAdapterState . displayName , devices : callAdapterState . devices , isLocalPreviewMicrophoneEnabled : callAdapterState . isLocalPreviewMicrophoneEnabled , isTeamsCall : callAdapterState . isTeamsCall } ; } private export function mergeChatAdapterStateIntoMeetingAdapterState ( meetingAdapterState , chatAdapterState ) { const newMeetingState = meetingAdapterState . meeting ? mergeChatStateIntoMeetingState ( meetingAdapterState . meeting , chatAdapterState . thread ) : undefined ; return { ... meetingAdapterState , meeting : newMeetingState } ; } private export function mergeCallAdapterStateIntoMeetingAdapterState ( meetingAdapterState , callAdapterState ) { const newMeetingState = callAdapterState . call ? mergeCallStateIntoMeetingState ( meetingAdapterState . meeting , callAdapterState . call ) : undefined ; return { userId : callAdapterState . userId , page : callPageToMeetingPage ( callAdapterState . page ) , displayName : callAdapterState . displayName , devices : callAdapterState . devices , meeting : newMeetingState , isLocalPreviewMicrophoneEnabled : callAdapterState . isLocalPreviewMicrophoneEnabled , isTeamsCall : callAdapterState . isTeamsCall } ; }