a693133b5a
There are a couple of hardcoded UA checks targeted at iOS endpoints introduced circa 2.2-beta. One of those pops up an "unsupported" toast when the device joins a conference - the other blocks camera sharing. Those checks are outdated since we transitioned to minBrowserVersions approach that redirects the client to an unsupported view upon join. I also assume the checks are bugged since, in some environments, it flags iPadOS endpoints as iOS and version-checks it to a hardcoded "12.2" threshold (which is incompatible with iPadOS versioning). That caused camera sharing not to work, which is a false negative. I consider the checks to be outdated, so I removed all references to them.
193 lines
5.4 KiB
JavaScript
Executable File
193 lines
5.4 KiB
JavaScript
Executable File
import React, { memo } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import ButtonEmoji from '/imports/ui/components/common/button/button-emoji/ButtonEmoji';
|
|
import VideoService from '../service';
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
import Styled from './styles';
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
|
import { debounce } from 'lodash';
|
|
import BBBMenu from '/imports/ui/components/common/menu/component';
|
|
import { isVirtualBackgroundsEnabled } from '/imports/ui/services/features';
|
|
import Button from '/imports/ui/components/common/button/component';
|
|
|
|
const ENABLE_WEBCAM_SELECTOR_BUTTON = Meteor.settings.public.app.enableWebcamSelectorButton;
|
|
const ENABLE_CAMERA_BRIGHTNESS = Meteor.settings.public.app.enableCameraBrightness;
|
|
|
|
const intlMessages = defineMessages({
|
|
videoSettings: {
|
|
id: 'app.video.videoSettings',
|
|
description: 'Open video settings',
|
|
},
|
|
visualEffects: {
|
|
id: 'app.video.visualEffects',
|
|
description: 'Visual effects label',
|
|
},
|
|
joinVideo: {
|
|
id: 'app.video.joinVideo',
|
|
description: 'Join video button label',
|
|
},
|
|
leaveVideo: {
|
|
id: 'app.video.leaveVideo',
|
|
description: 'Leave video button label',
|
|
},
|
|
advancedVideo: {
|
|
id: 'app.video.advancedVideo',
|
|
description: 'Open advanced video label',
|
|
},
|
|
videoLocked: {
|
|
id: 'app.video.videoLocked',
|
|
description: 'video disabled label',
|
|
},
|
|
videoConnecting: {
|
|
id: 'app.video.connecting',
|
|
description: 'video connecting label',
|
|
},
|
|
camCapReached: {
|
|
id: 'app.video.meetingCamCapReached',
|
|
description: 'meeting camera cap label',
|
|
},
|
|
meteorDisconnected: {
|
|
id: 'app.video.clientDisconnected',
|
|
description: 'Meteor disconnected label',
|
|
},
|
|
});
|
|
|
|
const JOIN_VIDEO_DELAY_MILLISECONDS = 500;
|
|
|
|
const propTypes = {
|
|
intl: PropTypes.object.isRequired,
|
|
hasVideoStream: PropTypes.bool.isRequired,
|
|
status: PropTypes.string.isRequired,
|
|
mountVideoPreview: PropTypes.func.isRequired,
|
|
};
|
|
|
|
const JoinVideoButton = ({
|
|
intl,
|
|
hasVideoStream,
|
|
status,
|
|
disableReason,
|
|
mountVideoPreview,
|
|
}) => {
|
|
const { isMobile } = deviceInfo;
|
|
const isMobileSharingCamera = hasVideoStream && isMobile;
|
|
const isDesktopSharingCamera = hasVideoStream && !isMobile;
|
|
const shouldEnableWebcamSelectorButton = ENABLE_WEBCAM_SELECTOR_BUTTON
|
|
&& isDesktopSharingCamera;
|
|
const shouldEnableWebcamVisualEffectsButton =
|
|
(isVirtualBackgroundsEnabled() || ENABLE_CAMERA_BRIGHTNESS)
|
|
&& hasVideoStream
|
|
&& !isMobile;
|
|
const exitVideo = () => isDesktopSharingCamera && (!VideoService.isMultipleCamerasEnabled()
|
|
|| shouldEnableWebcamSelectorButton);
|
|
|
|
const handleOnClick = debounce(() => {
|
|
switch (status) {
|
|
case 'videoConnecting':
|
|
VideoService.stopVideo();
|
|
break;
|
|
case 'connected':
|
|
default:
|
|
if (exitVideo()) {
|
|
VideoService.exitVideo();
|
|
} else {
|
|
mountVideoPreview(isMobileSharingCamera);
|
|
}
|
|
}
|
|
}, JOIN_VIDEO_DELAY_MILLISECONDS);
|
|
|
|
const handleOpenAdvancedOptions = (props) => {
|
|
mountVideoPreview(isDesktopSharingCamera, props);
|
|
};
|
|
|
|
const getMessageFromStatus = () => {
|
|
let statusMessage = status;
|
|
if (status !== 'videoConnecting') {
|
|
statusMessage = exitVideo() ? 'leaveVideo' : 'joinVideo';
|
|
}
|
|
return statusMessage;
|
|
};
|
|
|
|
const label = disableReason
|
|
? intl.formatMessage(intlMessages[disableReason])
|
|
: intl.formatMessage(intlMessages[getMessageFromStatus()]);
|
|
|
|
const isSharing = hasVideoStream || status === 'videoConnecting';
|
|
|
|
const renderUserActions = () => {
|
|
const actions = [];
|
|
|
|
if (shouldEnableWebcamSelectorButton) {
|
|
actions.push(
|
|
{
|
|
key: 'advancedVideo',
|
|
label: intl.formatMessage(intlMessages.advancedVideo),
|
|
onClick: () => handleOpenAdvancedOptions(),
|
|
dataTest: 'advancedVideoSettingsButton',
|
|
},
|
|
);
|
|
}
|
|
|
|
if (shouldEnableWebcamVisualEffectsButton) {
|
|
actions.push(
|
|
{
|
|
key: 'virtualBgSelection',
|
|
label: intl.formatMessage(intlMessages.visualEffects),
|
|
onClick: () => handleOpenAdvancedOptions({ isVisualEffects: true }),
|
|
},
|
|
);
|
|
}
|
|
|
|
if (actions.length === 0) return null;
|
|
const customStyles = { top: '-3.6rem' };
|
|
|
|
return (
|
|
<BBBMenu
|
|
customStyles={!isMobile ? customStyles : null}
|
|
trigger={(
|
|
<ButtonEmoji
|
|
emoji="device_list_selector"
|
|
data-test="videoDropdownMenu"
|
|
hideLabel
|
|
label={intl.formatMessage(intlMessages.videoSettings)}
|
|
rotate
|
|
tabIndex={0}
|
|
/>
|
|
)}
|
|
actions={actions}
|
|
opts={{
|
|
id: "video-dropdown-menu",
|
|
keepMounted: true,
|
|
transitionDuration: 0,
|
|
elevation: 3,
|
|
getContentAnchorEl: null,
|
|
fullwidth: "true",
|
|
anchorOrigin: { vertical: 'top', horizontal: 'center' },
|
|
transformOrigin: { vertical: 'top', horizontal: 'center'},
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Styled.OffsetBottom>
|
|
<Button
|
|
label={label}
|
|
data-test={hasVideoStream ? 'leaveVideo' : 'joinVideo'}
|
|
onClick={handleOnClick}
|
|
hideLabel
|
|
color={isSharing ? 'primary' : 'default'}
|
|
icon={isSharing ? 'video' : 'video_off'}
|
|
ghost={!isSharing}
|
|
size="lg"
|
|
circle
|
|
disabled={!!disableReason}
|
|
/>
|
|
{renderUserActions()}
|
|
</Styled.OffsetBottom>
|
|
);
|
|
};
|
|
|
|
JoinVideoButton.propTypes = propTypes;
|
|
|
|
export default injectIntl(memo(JoinVideoButton));
|