Skip to content

Commit cf8225f

Browse files
authored
[Stable blocking] Prevent showing screenShareButton when formFactor is set to mobile (#3915)
* Revise bug fix to hide screenshare button for iOS * Prevent showing screenShareButton when formFactor is set to mobile * Change files * Duplicate change files for beta release * refactor
1 parent 4a328c8 commit cf8225f

6 files changed

Lines changed: 47 additions & 12 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "none",
3+
"area": "fix",
4+
"workstream": "Screenshare button",
5+
"comment": "Prevent showing screenShareButton when formFactor is set to mobile",
6+
"packageName": "@azure/communication-react",
7+
"email": "79475487+mgamis-msft@users.noreply.github.com",
8+
"dependentChangeType": "none"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "none",
3+
"area": "fix",
4+
"workstream": "Screenshare button",
5+
"comment": "Prevent showing screenShareButton when formFactor is set to mobile",
6+
"packageName": "@azure/communication-react",
7+
"email": "79475487+mgamis-msft@users.noreply.github.com",
8+
"dependentChangeType": "none"
9+
}

packages/react-composites/src/composites/CallComposite/components/CallControls.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,31 @@ export type CallControlsProps = {
6969
// Enforce a background color on control bar to ensure it matches the composite background color.
7070
const controlBarStyles = memoizeFunction((background: string) => ({ root: { background: background } }));
7171

72+
const inferCallControlOptions = (
73+
mobileView: boolean,
74+
callControlOptions?: boolean | CallControlOptions
75+
): CallControlOptions => {
76+
if (callControlOptions === false) {
77+
return {};
78+
}
79+
80+
const options = callControlOptions === true || callControlOptions === undefined ? {} : callControlOptions;
81+
if (mobileView) {
82+
// Set options to always not show screen share button for mobile
83+
options.screenShareButton = false;
84+
}
85+
return options;
86+
};
87+
7288
/**
7389
* @private
7490
*/
7591
export const CallControls = (props: CallControlsProps & ContainerRectProps): JSX.Element => {
76-
const options = useMemo(() => (typeof props.options === 'boolean' ? {} : props.options), [props.options]);
92+
const options: CallControlOptions = useMemo(
93+
() => inferCallControlOptions(!!props.isMobile, props.options),
94+
[props.isMobile, props.options]
95+
);
96+
7797
/* @conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(rooms) */
7898
const adapter = useAdapter();
7999

packages/react-composites/src/composites/common/ControlBar/CommonCallControlBar.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,8 @@ const inferCommonCallControlOptions = (
8989
if (mobileView) {
9090
// Set to compressed mode when composite is optimized for mobile
9191
options.displayType = 'compact';
92-
// Do not show screen share button when composite is optimized for mobile unless the developer
93-
// has explicitly opted in.
94-
if (options.screenShareButton !== true) {
95-
options.screenShareButton = false;
96-
}
92+
// Set options to always not show screen share button for mobile
93+
options.screenShareButton = false;
9794
}
9895
return options;
9996
};

samples/CallWithChat/src/app/views/CallScreen.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,15 @@ export const CallScreen = (props: CallScreenProps): JSX.Element => {
146146
afterAdapterCreate
147147
);
148148

149-
const shouldDisableScreenShare = isIOS();
149+
const shouldHideScreenShare = isMobileSession || isIOS();
150150

151151
const options: CallWithChatCompositeOptions = useMemo(
152152
() => ({
153153
callControls: {
154-
screenShareButton: !shouldDisableScreenShare
154+
screenShareButton: shouldHideScreenShare ? false : undefined
155155
}
156156
}),
157-
[shouldDisableScreenShare]
157+
[shouldHideScreenShare]
158158
);
159159

160160
// Dispose of the adapter in the window's before unload event.

samples/Calling/src/app/views/CallCompositeContainer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ export const CallCompositeContainer = (props: CallCompositeContainerProps): JSX.
1616
const { adapter } = props;
1717
const { currentTheme, currentRtl } = useSwitchableFluentTheme();
1818
const isMobileSession = useIsMobile();
19-
const shouldDisableScreenShare = isIOS();
19+
const shouldHideScreenShare = isMobileSession || isIOS();
2020

2121
const options: CallCompositeOptions = useMemo(
2222
() => ({
2323
/* @conditional-compile-remove(call-readiness) */ onPermissionsTroubleshootingClick,
2424
/* @conditional-compile-remove(call-readiness) */ onNetworkingTroubleShootingClick,
2525
callControls: {
26-
screenShareButton: !shouldDisableScreenShare
26+
screenShareButton: shouldHideScreenShare ? false : undefined
2727
}
2828
}),
29-
[shouldDisableScreenShare]
29+
[shouldHideScreenShare]
3030
);
3131

3232
// Dispose of the adapter in the window's before unload event.

0 commit comments

Comments
 (0)