|
@@ -1,10 +1,13 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
|
3
|
+import { batch } from 'react-redux';
|
|
4
|
+
|
3
|
5
|
import UIEvents from '../../../../service/UI/UIEvents';
|
4
|
6
|
import { showModeratedNotification } from '../../av-moderation/actions';
|
5
|
7
|
import { shouldShowModeratedNotification } from '../../av-moderation/functions';
|
6
|
8
|
import { hideNotification, isModerationNotificationDisplayed } from '../../notifications';
|
7
|
9
|
import { isPrejoinPageVisible } from '../../prejoin/functions';
|
|
10
|
+import { getCurrentConference } from '../conference/functions';
|
8
|
11
|
import { getAvailableDevices } from '../devices/actions';
|
9
|
12
|
import {
|
10
|
13
|
CAMERA_FACING_MODE,
|
|
@@ -17,7 +20,7 @@ import {
|
17
|
20
|
toggleCameraFacingMode,
|
18
|
21
|
VIDEO_TYPE
|
19
|
22
|
} from '../media';
|
20
|
|
-import { MiddlewareRegistry } from '../redux';
|
|
23
|
+import { MiddlewareRegistry, StateListenerRegistry } from '../redux';
|
21
|
24
|
|
22
|
25
|
import {
|
23
|
26
|
TRACK_ADDED,
|
|
@@ -30,6 +33,7 @@ import {
|
30
|
33
|
createLocalTracksA,
|
31
|
34
|
showNoDataFromSourceVideoError,
|
32
|
35
|
toggleScreensharing,
|
|
36
|
+ trackRemoved,
|
33
|
37
|
trackNoDataFromSourceNotificationInfoChanged
|
34
|
38
|
} from './actions';
|
35
|
39
|
import {
|
|
@@ -204,6 +208,25 @@ MiddlewareRegistry.register(store => next => action => {
|
204
|
208
|
return next(action);
|
205
|
209
|
});
|
206
|
210
|
|
|
211
|
+/**
|
|
212
|
+ * Set up state change listener to perform maintenance tasks when the conference
|
|
213
|
+ * is left or failed, remove all remote tracks from the store.
|
|
214
|
+ */
|
|
215
|
+StateListenerRegistry.register(
|
|
216
|
+ state => getCurrentConference(state),
|
|
217
|
+ (conference, { dispatch, getState }, prevConference) => {
|
|
218
|
+ if (prevConference && !conference) {
|
|
219
|
+ // Clear all remote tracks.
|
|
220
|
+ const remoteTracks = getState()['features/base/tracks'].filter(t => !t.local);
|
|
221
|
+
|
|
222
|
+ batch(() => {
|
|
223
|
+ for (const track of remoteTracks) {
|
|
224
|
+ dispatch(trackRemoved(track.jitsiTrack));
|
|
225
|
+ }
|
|
226
|
+ });
|
|
227
|
+ }
|
|
228
|
+ });
|
|
229
|
+
|
207
|
230
|
/**
|
208
|
231
|
* Handles no data from source errors.
|
209
|
232
|
*
|