Fix stop everyone's video

Stop everyone's video now also stops screensharing for the moderator that did the action, not just video
This commit is contained in:
robertpin 2021-09-22 15:11:43 +03:00 committed by Horatiu Muresan
parent 92f1985219
commit 41c38427c1
4 changed files with 23 additions and 13 deletions

View File

@ -1503,14 +1503,14 @@ export default {
*
* @param {boolean} didHaveVideo indicates if there was a camera video being
* used, before switching to screen sharing.
* @param {boolean} wasVideoMuted indicates if the video was muted, before
* switching to screen sharing.
* @param {boolean} ignoreDidHaveVideo indicates if the camera video should be
* ignored when switching screen sharing off.
* @return {Promise} resolved after the screen sharing is turned off, or
* rejected with some error (no idea what kind of error, possible GUM error)
* in case it fails.
* @private
*/
async _turnScreenSharingOff(didHaveVideo) {
async _turnScreenSharingOff(didHaveVideo, ignoreDidHaveVideo) {
this._untoggleScreenSharing = null;
this.videoSwitchInProgress = true;
@ -1554,7 +1554,7 @@ export default {
APP.store.dispatch(setScreenAudioShareState(false));
if (didHaveVideo) {
if (didHaveVideo && !ignoreDidHaveVideo) {
promise = promise.then(() => createLocalTracksF({ devices: [ 'video' ] }))
.then(([ stream ]) => {
logger.debug(`_turnScreenSharingOff using ${stream} for useVideoStream`);
@ -1605,9 +1605,10 @@ export default {
* @param {Array<string>} [options.desktopSharingSources] - Array with the
* sources that have to be displayed in the desktop picker window ('screen',
* 'window', etc.).
* @param {boolean} ignoreDidHaveVideo - if true ignore if video was on when sharing started.
* @return {Promise.<T>}
*/
async toggleScreenSharing(toggle = !this._untoggleScreenSharing, options = {}) {
async toggleScreenSharing(toggle = !this._untoggleScreenSharing, options = {}, ignoreDidHaveVideo) {
logger.debug(`toggleScreenSharing: ${toggle}`);
if (this.videoSwitchInProgress) {
return Promise.reject('Switch in progress.');
@ -1633,7 +1634,7 @@ export default {
}
return this._untoggleScreenSharing
? this._untoggleScreenSharing()
? this._untoggleScreenSharing(ignoreDidHaveVideo)
: Promise.resolve();
},
@ -2476,8 +2477,8 @@ export default {
});
APP.UI.addListener(
UIEvents.TOGGLE_SCREENSHARING, ({ enabled, audioOnly }) => {
this.toggleScreenSharing(enabled, { audioOnly });
UIEvents.TOGGLE_SCREENSHARING, ({ enabled, audioOnly, ignoreDidHaveVideo }) => {
this.toggleScreenSharing(enabled, { audioOnly }, ignoreDidHaveVideo);
}
);
},

View File

@ -258,17 +258,20 @@ export function showNoDataFromSourceVideoError(jitsiTrack) {
*
* @param {boolean} enabled - The state to toggle screen sharing to.
* @param {boolean} audioOnly - Only share system audio.
* @param {boolean} ignoreDidHaveVideo - Wether or not to ignore if video was on when sharing started.
* @returns {{
* type: TOGGLE_SCREENSHARING,
* on: boolean,
* audioOnly: boolean
* audioOnly: boolean,
* ignoreDidHaveVideo: boolean
* }}
*/
export function toggleScreensharing(enabled, audioOnly = false) {
export function toggleScreensharing(enabled, audioOnly = false, ignoreDidHaveVideo = false) {
return {
type: TOGGLE_SCREENSHARING,
enabled,
audioOnly
audioOnly,
ignoreDidHaveVideo
};
}

View File

@ -149,10 +149,11 @@ MiddlewareRegistry.register(store => next => action => {
return;
}
const { enabled, audioOnly } = action;
const { enabled, audioOnly, ignoreDidHaveVideo } = action;
APP.UI.emitEvent(UIEvents.TOGGLE_SCREENSHARING, { enabled,
audioOnly });
audioOnly,
ignoreDidHaveVideo });
}
break;

View File

@ -23,6 +23,7 @@ import {
getRemoteParticipants,
muteRemoteParticipant
} from '../base/participants';
import { toggleScreensharing } from '../base/tracks';
import { isModerationNotificationDisplayed } from '../notifications';
declare var APP: Object;
@ -55,6 +56,10 @@ export function muteLocal(enable: boolean, mediaType: MEDIA_TYPE) {
return;
}
if (enable) {
dispatch(toggleScreensharing(false, false, true));
}
sendAnalytics(createToolbarEvent(isAudio ? AUDIO_MUTE : VIDEO_MUTE, { enable }));
dispatch(isAudio ? setAudioMuted(enable, /* ensureTrack */ true)
: setVideoMuted(enable, mediaType, VIDEO_MUTISM_AUTHORITY.USER, /* ensureTrack */ true));