fix(conference) simplify code

Unify the 2 functions used to leave the room into a single one.
This commit is contained in:
Saúl Ibarra Corretgé 2021-11-30 10:13:44 +01:00 committed by Дамян Минков
parent 599ed10325
commit 43647f1302
3 changed files with 17 additions and 18 deletions

View File

@ -9,6 +9,7 @@ import { ENDPOINT_TEXT_MESSAGE_NAME } from './modules/API/constants';
import { AUDIO_ONLY_SCREEN_SHARE_NO_TRACK } from './modules/UI/UIErrors';
import AuthHandler from './modules/UI/authentication/AuthHandler';
import UIUtil from './modules/UI/util/UIUtil';
import VideoLayout from './modules/UI/videolayout/VideoLayout';
import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
import Recorder from './modules/recorder/Recorder';
import { createTaskQueue } from './modules/util/helpers';
@ -1329,6 +1330,10 @@ export default {
* Used by the Breakout Rooms feature to join a breakout room or go back to the main room.
*/
async joinRoom(roomName) {
// Reset VideoLayout. It's destroyed in features/video-layout/middleware.web.js so re-initialize it.
VideoLayout.initLargeVideo();
VideoLayout.resizeVideoArea();
this.roomName = roomName;
const { tryCreateLocalTracks, errors } = this.createInitialLocalTracks();
@ -2884,7 +2889,7 @@ export default {
Promise.all([
requestFeedbackPromise,
this.leaveRoomAndDisconnect()
this.leaveRoom()
])
.then(values => {
this._room = undefined;
@ -2905,27 +2910,23 @@ export default {
/**
* Leaves the room.
*
* @param {boolean} doDisconnect - Wether leaving the room should also terminate the connection.
* @returns {Promise}
*/
leaveRoom() {
if (room && room.isJoined()) {
return room.leave();
}
},
/**
* Leaves the room and calls JitsiConnection.disconnect.
*
* @returns {Promise}
*/
leaveRoomAndDisconnect() {
leaveRoom(doDisconnect = true) {
APP.store.dispatch(conferenceWillLeave(room));
if (room && room.isJoined()) {
return room.leave().then(disconnect, disconnect);
return room.leave().finally(() => {
if (doDisconnect) {
return disconnect();
}
});
}
if (doDisconnect) {
return disconnect();
}
},
/**

View File

@ -199,7 +199,7 @@ export function moveToRoom(roomId?: string) {
dispatch(setAudioMuted(audio.muted));
dispatch(setVideoMuted(video.muted));
} else {
APP.conference.leaveRoom()
APP.conference.leaveRoom(false /* doDisconnect */)
.finally(() => APP.conference.joinRoom(_roomId));
}
};

View File

@ -15,8 +15,6 @@ import { PARTICIPANTS_PANE_CLOSE, PARTICIPANTS_PANE_OPEN } from '../participants
import './middleware.any';
declare var APP: Object;
/**
* Middleware which intercepts actions and updates the legacy component
* {@code VideoLayout} as needed. The purpose of this middleware is to redux-ify