fix(breakout-rooms) cleanup remote tracks when a conference is left

This commit is contained in:
Saúl Ibarra Corretgé 2021-12-08 22:20:26 +01:00 committed by Дамян Минков
parent 085b07efcd
commit c48aa44af3
1 changed files with 24 additions and 1 deletions

View File

@ -1,10 +1,13 @@
// @flow // @flow
import { batch } from 'react-redux';
import UIEvents from '../../../../service/UI/UIEvents'; import UIEvents from '../../../../service/UI/UIEvents';
import { showModeratedNotification } from '../../av-moderation/actions'; import { showModeratedNotification } from '../../av-moderation/actions';
import { shouldShowModeratedNotification } from '../../av-moderation/functions'; import { shouldShowModeratedNotification } from '../../av-moderation/functions';
import { hideNotification, isModerationNotificationDisplayed } from '../../notifications'; import { hideNotification, isModerationNotificationDisplayed } from '../../notifications';
import { isPrejoinPageVisible } from '../../prejoin/functions'; import { isPrejoinPageVisible } from '../../prejoin/functions';
import { getCurrentConference } from '../conference/functions';
import { getAvailableDevices } from '../devices/actions'; import { getAvailableDevices } from '../devices/actions';
import { import {
CAMERA_FACING_MODE, CAMERA_FACING_MODE,
@ -17,7 +20,7 @@ import {
toggleCameraFacingMode, toggleCameraFacingMode,
VIDEO_TYPE VIDEO_TYPE
} from '../media'; } from '../media';
import { MiddlewareRegistry } from '../redux'; import { MiddlewareRegistry, StateListenerRegistry } from '../redux';
import { import {
TRACK_ADDED, TRACK_ADDED,
@ -30,6 +33,7 @@ import {
createLocalTracksA, createLocalTracksA,
showNoDataFromSourceVideoError, showNoDataFromSourceVideoError,
toggleScreensharing, toggleScreensharing,
trackRemoved,
trackNoDataFromSourceNotificationInfoChanged trackNoDataFromSourceNotificationInfoChanged
} from './actions'; } from './actions';
import { import {
@ -204,6 +208,25 @@ MiddlewareRegistry.register(store => next => action => {
return next(action); return next(action);
}); });
/**
* Set up state change listener to perform maintenance tasks when the conference
* is left or failed, remove all remote tracks from the store.
*/
StateListenerRegistry.register(
state => getCurrentConference(state),
(conference, { dispatch, getState }, prevConference) => {
if (prevConference && !conference) {
// Clear all remote tracks.
const remoteTracks = getState()['features/base/tracks'].filter(t => !t.local);
batch(() => {
for (const track of remoteTracks) {
dispatch(trackRemoved(track.jitsiTrack));
}
});
}
});
/** /**
* Handles no data from source errors. * Handles no data from source errors.
* *