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

View File

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

View File

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