Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "none",
"area": "fix",
"workstream": "Screenshare button",
"comment": "Prevent showing screenShareButton when formFactor is set to mobile",
"packageName": "@azure/communication-react",
"email": "79475487+mgamis-msft@users.noreply.github.com",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "none",
"area": "fix",
"workstream": "Screenshare button",
"comment": "Prevent showing screenShareButton when formFactor is set to mobile",
"packageName": "@azure/communication-react",
"email": "79475487+mgamis-msft@users.noreply.github.com",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,31 @@ export type CallControlsProps = {
// Enforce a background color on control bar to ensure it matches the composite background color.
const controlBarStyles = memoizeFunction((background: string) => ({ root: { background: background } }));

const inferCallControlOptions = (
mobileView: boolean,
callControlOptions?: boolean | CallControlOptions
): CallControlOptions => {
if (callControlOptions === false) {
return {};
}

const options = callControlOptions === true || callControlOptions === undefined ? {} : callControlOptions;
if (mobileView) {
// Set options to always not show screen share button for mobile
options.screenShareButton = false;
}
return options;
};

/**
* @private
*/
export const CallControls = (props: CallControlsProps & ContainerRectProps): JSX.Element => {
const options = useMemo(() => (typeof props.options === 'boolean' ? {} : props.options), [props.options]);
const options: CallControlOptions = useMemo(
() => inferCallControlOptions(!!props.isMobile, props.options),
[props.isMobile, props.options]
);

/* @conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(rooms) */
const adapter = useAdapter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ const inferCommonCallControlOptions = (
if (mobileView) {
// Set to compressed mode when composite is optimized for mobile
options.displayType = 'compact';
// Do not show screen share button when composite is optimized for mobile unless the developer
// has explicitly opted in.
if (options.screenShareButton !== true) {
options.screenShareButton = false;
}
// Set options to always not show screen share button for mobile
options.screenShareButton = false;
}
return options;
};
Expand Down
8 changes: 5 additions & 3 deletions samples/CallWithChat/src/app/views/CallScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ export const CallScreen = (props: CallScreenProps): JSX.Element => {

const options: CallWithChatCompositeOptions = useMemo(
() => ({
callControls: {
screenShareButton: !shouldDisableScreenShare
Comment thread
JamesBurnside marked this conversation as resolved.
}
callControls: shouldDisableScreenShare
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid setting the whole callControls object based on shouldDisableScreenShare, makes it hard for someone to add options to this in future (they'd have to move the shouldDisableScreenShare)
Instead can we do:

callControls: {
  screenShareButton: shouldDisableScreenShare ? false : undefined
}

?

Copy link
Copy Markdown
Member

@JamesBurnside JamesBurnside Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Or fix the shouldDisableScreenshare to be isMobile || isIOS instead of just isIOS)

? {
screenShareButton: false
}
: undefined
}),
[shouldDisableScreenShare]
);
Expand Down
8 changes: 5 additions & 3 deletions samples/Calling/src/app/views/CallCompositeContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ export const CallCompositeContainer = (props: CallCompositeContainerProps): JSX.
() => ({
/* @conditional-compile-remove(call-readiness) */ onPermissionsTroubleshootingClick,
/* @conditional-compile-remove(call-readiness) */ onNetworkingTroubleShootingClick,
callControls: {
screenShareButton: !shouldDisableScreenShare
}
callControls: shouldDisableScreenShare
? {
screenShareButton: false
}
: undefined
}),
[shouldDisableScreenShare]
);
Expand Down