-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathCallPage.tsx
More file actions
167 lines (158 loc) · 7.57 KB
/
CallPage.tsx
File metadata and controls
167 lines (158 loc) · 7.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { DiagnosticQuality } from '@azure/communication-calling';
import { useId } from '@fluentui/react-hooks';
import { _isInCall } from '@internal/calling-component-bindings';
import { ActiveErrorMessage, ErrorBar, ParticipantMenuItemsCallback } from '@internal/react-components';
/* @conditional-compile-remove(gallery-layouts) */
import { VideoGalleryLayout } from '@internal/react-components';
import React from 'react';
import { AvatarPersonaDataCallback } from '../../common/AvatarPersona';
import { useLocale } from '../../localization';
import { CallCompositeOptions } from '../CallComposite';
import { CallArrangement } from '../components/CallArrangement';
import { MediaGallery } from '../components/MediaGallery';
import { NetworkReconnectTile } from '../components/NetworkReconnectTile';
import { useHandlers } from '../hooks/useHandlers';
import { usePropsFor } from '../hooks/usePropsFor';
import { useSelector } from '../hooks/useSelector';
import { callStatusSelector } from '../selectors/callStatusSelector';
import { complianceBannerSelector } from '../selectors/complianceBannerSelector';
import { mediaGallerySelector } from '../selectors/mediaGallerySelector';
import { mutedNotificationSelector } from '../selectors/mutedNotificationSelector';
import { networkReconnectTileSelector } from '../selectors/networkReconnectTileSelector';
import { reduceCallControlsForMobile } from '../utils';
import { MobileChatSidePaneTabHeaderProps } from '../../common/TabHeader';
import { SidePaneRenderer } from '../components/SidePane/SidePaneProvider';
/* @conditional-compile-remove(capabilities) */
import { CapabilitiesChangeNotificationBarProps } from '../components/CapabilitiesChangedNotificationBar';
/**
* @private
*/
export interface CallPageProps {
mobileView: boolean;
modalLayerHostId: string;
callInvitationURL?: string;
onFetchAvatarPersonaData?: AvatarPersonaDataCallback;
onFetchParticipantMenuItems?: ParticipantMenuItemsCallback;
updateSidePaneRenderer: (renderer: SidePaneRenderer | undefined) => void;
mobileChatTabHeader?: MobileChatSidePaneTabHeaderProps;
options?: CallCompositeOptions;
latestErrors: ActiveErrorMessage[];
onDismissError: (error: ActiveErrorMessage) => void;
/* @conditional-compile-remove(gallery-layouts) */
galleryLayout: VideoGalleryLayout;
/* @conditional-compile-remove(capabilities) */
capabilitiesChangedNotificationBarProps?: CapabilitiesChangeNotificationBarProps;
/* @conditional-compile-remove(gallery-layouts) */
onUserSetGalleryLayoutChange?: (layout: VideoGalleryLayout) => void;
/* @conditional-compile-remove(gallery-layouts) */
userSetOverflowGalleryPosition?: 'Responsive' | 'horizontalTop';
/* @conditional-compile-remove(gallery-layouts) */
onSetUserSetOverflowGalleryPosition?: (position: 'Responsive' | 'horizontalTop') => void;
onCloseChatPane?: () => void;
/* @conditional-compile-remove(dtmf-dialer) */
onSetDialpadPage: () => void;
}
/**
* @private
*/
export const CallPage = (props: CallPageProps): JSX.Element => {
const {
callInvitationURL,
onFetchAvatarPersonaData,
onFetchParticipantMenuItems,
options,
mobileView,
/* @conditional-compile-remove(gallery-layouts) */
galleryLayout = 'floatingLocalVideo',
/* @conditional-compile-remove(gallery-layouts) */
onUserSetGalleryLayoutChange,
/* @conditional-compile-remove(gallery-layouts) */
userSetOverflowGalleryPosition = 'Responsive',
/* @conditional-compile-remove(gallery-layouts) */
onSetUserSetOverflowGalleryPosition,
onCloseChatPane
} = props;
// To use useProps to get these states, we need to create another file wrapping Call,
// It seems unnecessary in this case, so we get the updated states using this approach.
const { callStatus } = useSelector(callStatusSelector);
const mediaGalleryProps = useSelector(mediaGallerySelector);
const mediaGalleryHandlers = useHandlers(MediaGallery);
const complianceBannerProps = useSelector(complianceBannerSelector);
const errorBarProps = usePropsFor(ErrorBar);
const mutedNotificationProps = useSelector(mutedNotificationSelector);
const networkReconnectTileProps = useSelector(networkReconnectTileSelector);
const strings = useLocale().strings.call;
// Reduce the controls shown when mobile view is enabled.
const callControlOptions = mobileView ? reduceCallControlsForMobile(options?.callControls) : options?.callControls;
const drawerMenuHostId = useId('drawerMenuHost');
return (
<CallArrangement
id={drawerMenuHostId}
complianceBannerProps={{ ...complianceBannerProps, strings }}
errorBarProps={options?.errorBar !== false && errorBarProps}
mutedNotificationProps={mutedNotificationProps}
callControlProps={{
callInvitationURL: callInvitationURL,
onFetchParticipantMenuItems: onFetchParticipantMenuItems,
options: callControlOptions,
increaseFlyoutItemSize: mobileView
}}
/* @conditional-compile-remove(one-to-n-calling) */ /* @conditional-compile-remove(close-captions) */
onFetchAvatarPersonaData={onFetchAvatarPersonaData}
mobileView={mobileView}
modalLayerHostId={props.modalLayerHostId}
onRenderGalleryContent={() =>
_isInCall(callStatus) ? (
isNetworkHealthy(networkReconnectTileProps.networkReconnectValue) ? (
<MediaGallery
isMobile={mobileView}
{...mediaGalleryProps}
{...mediaGalleryHandlers}
onFetchAvatarPersonaData={onFetchAvatarPersonaData}
/* @conditional-compile-remove(pinned-participants) */
remoteVideoTileMenuOptions={options?.remoteVideoTileMenuOptions}
drawerMenuHostId={drawerMenuHostId}
/* @conditional-compile-remove(click-to-call) */
localVideoTileOptions={options?.localVideoTile}
/* @conditional-compile-remove(gallery-layouts) */
userSetOverflowGalleryPosition={userSetOverflowGalleryPosition}
/* @conditional-compile-remove(gallery-layouts) */
userSetGalleryLayout={galleryLayout}
/>
) : (
<NetworkReconnectTile {...networkReconnectTileProps} />
)
) : (
<></>
)
}
updateSidePaneRenderer={props.updateSidePaneRenderer}
mobileChatTabHeader={props.mobileChatTabHeader}
onCloseChatPane={onCloseChatPane}
dataUiId={'call-page'}
latestErrors={props.latestErrors}
onDismissError={props.onDismissError}
/* @conditional-compile-remove(gallery-layouts) */
onUserSetOverflowGalleryPositionChange={onSetUserSetOverflowGalleryPosition}
/* @conditional-compile-remove(gallery-layouts) */
onUserSetGalleryLayoutChange={onUserSetGalleryLayoutChange}
/* @conditional-compile-remove(gallery-layouts) */
userSetGalleryLayout={galleryLayout}
/* @conditional-compile-remove(capabilities) */
capabilitiesChangedNotificationBarProps={props.capabilitiesChangedNotificationBarProps}
/* @conditional-compile-remove(dtmf-dialer) */
onSetDialpadPage={props.onSetDialpadPage}
/>
);
};
/**
* @private
*/
export const isNetworkHealthy = (value: DiagnosticQuality | boolean | undefined): boolean => {
// We know that the value is actually of type DiagnosticQuality for this diagnostic.
// We ignore any boolen values, considering the network to still be healthy.
// Thus, only DiagnosticQuality.Poor or .Bad indicate network problems.
return value === true || value === false || value === undefined || value === DiagnosticQuality.Good;
};