Skip to content
Snippets Groups Projects
Unverified Commit 5b3cb27c authored by Chad Pilkey's avatar Chad Pilkey Committed by GitHub
Browse files

Merge pull request #8126 from lfzawacki/fix-swap-no-presentation

Fix auto swap race condition
parents b4c5d2cc 5dd46f8f
No related branches found
No related tags found
No related merge requests found
......@@ -10,31 +10,6 @@ import CaptionsButtonContainer from '/imports/ui/components/actions-bar/captions
import PresentationOptionsContainer from './presentation-options/component';
class ActionsBar extends PureComponent {
componentDidUpdate(prevProps) {
const { isThereCurrentPresentation: prevIsThereCurrPresentation } = prevProps;
const {
isThereCurrentPresentation,
getSwapLayout,
toggleSwapLayout,
isSharingVideo,
isVideoBroadcasting,
} = this.props;
if (!isThereCurrentPresentation && !isSharingVideo && !isVideoBroadcasting) {
if (!getSwapLayout()) {
toggleSwapLayout();
}
}
if (!prevIsThereCurrPresentation
&& isThereCurrentPresentation
&& !isSharingVideo
&& !isVideoBroadcasting) {
if (getSwapLayout()) {
toggleSwapLayout();
}
}
}
render() {
const {
......@@ -61,10 +36,10 @@ class ActionsBar extends PureComponent {
isMeteorConnected,
isPollingEnabled,
isThereCurrentPresentation,
allowExternalVideo,
} = this.props;
const actionBarClasses = {};
const { enabled: enableExternalVideo } = Meteor.settings.public.externalVideoPlayer;
actionBarClasses[styles.centerWithActions] = amIPresenter;
actionBarClasses[styles.center] = true;
......@@ -76,7 +51,7 @@ class ActionsBar extends PureComponent {
amIPresenter,
amIModerator,
isPollingEnabled,
allowExternalVideo: enableExternalVideo,
allowExternalVideo,
handleTakePresenter,
intl,
isSharingVideo,
......
......@@ -51,5 +51,5 @@ export default withTracker(() => ({
isPollingEnabled: POLLING_ENABLED,
isThereCurrentPresentation: Presentations.findOne({ meetingId: Auth.meetingID, current: true },
{ fields: {} }),
getSwapLayout,
allowExternalVideo: Meteor.settings.public.externalVideoPlayer.enabled,
}))(injectIntl(ActionsBarContainer));
......@@ -60,14 +60,11 @@ class ExternalVideoModal extends Component {
const {
startWatching,
closeModal,
toggleLayout,
isSwapped,
} = this.props;
const { url } = this.state;
startWatching(url.trim());
if (isSwapped) toggleLayout();
closeModal();
}
......
......@@ -3,7 +3,6 @@ import { withTracker } from 'meteor/react-meteor-data';
import { withModalMounter } from '/imports/ui/components/modal/service';
import ExternalVideoModal from './component';
import { startWatching, getVideoUrl } from '../service';
import mediaService from '/imports/ui/components/media/service';
const ExternalVideoModalContainer = props => <ExternalVideoModal {...props} />;
......@@ -13,6 +12,4 @@ export default withModalMounter(withTracker(({ mountModal }) => ({
},
startWatching,
videoUrl: getVideoUrl(),
toggleLayout: mediaService.toggleSwapLayout,
isSwapped: mediaService.getSwapLayout(),
}))(ExternalVideoModalContainer));
......@@ -105,6 +105,7 @@ export default withModalMounter(withTracker(() => {
const { dataSaving } = Settings;
const { viewParticipantsWebcams, viewScreenshare } = dataSaving;
const hidePresentation = getFromUserSettings('hidePresentation', LAYOUT_CONFIG.hidePresentation);
const { current_presentation: hasPresentation } = MediaService.getPresentationInfo();
const data = {
children: <DefaultContent />,
audioModalIsOpen: Session.get('audioModalIsOpen'),
......@@ -130,7 +131,7 @@ export default withModalMounter(withTracker(() => {
}
data.isScreensharing = MediaService.isVideoBroadcasting();
data.swapLayout = getSwapLayout() && shouldEnableSwapLayout();
data.swapLayout = (getSwapLayout() || !hasPresentation) && shouldEnableSwapLayout();
data.disableVideo = !viewParticipantsWebcams;
if (data.swapLayout) {
......
......@@ -62,10 +62,13 @@ export const shouldEnableSwapLayout = () => {
const { viewParticipantsWebcams } = Settings.dataSaving;
const usersVideo = VideoService.getAllWebcamUsers();
const poll = PollingService.mapPolls();
const { current_presentation: hasPresentation } = getPresentationInfo();
return usersVideo.length > 0 // prevent swap without any webcams
&& viewParticipantsWebcams // prevent swap when dataSaving for webcams is enabled
&& !poll.pollExists; // prevent swap when there is a poll running
&& !poll.pollExists // prevent swap when there is a poll running
&& !shouldShowScreenshare() // and when there's screenshare
&& !shouldShowExternalVideo() // or there's an external video
};
export const getSwapLayout = () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment