Browse Source

Remove remote participants who are no longer of interest

The Jitsi Meet app always has at most 1 conference of primary interest.
It may have to juggle with 2 JitsiConference instances at the same time
if 1 is in the process of being left and one is joining/joined. But the
one which is joining or joined (which we call conference in the
features/base/conference redux state) is the one "of interest", the
other one is "clean up". Consequently, the remote participants of the
conference "of interest" are the remote participants "of interest" and
the others are "clean up". In order to reduce the time during which
there may be multiplying remote thumbnails, clean the remote
participants who are no longer "of interest" up.
master
Lyubo Marinov 7 years ago
parent
commit
ee9fcbb735
1 changed files with 22 additions and 1 deletions
  1. 22
    1
      react/features/base/participants/middleware.js

+ 22
- 1
react/features/base/participants/middleware.js View File

@@ -2,13 +2,14 @@
2 2
 
3 3
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../app';
4 4
 import { CONFERENCE_LEFT, CONFERENCE_WILL_JOIN } from '../conference';
5
-import { MiddlewareRegistry } from '../redux';
5
+import { MiddlewareRegistry, StateListenerRegistry } from '../redux';
6 6
 import UIEvents from '../../../../service/UI/UIEvents';
7 7
 import { playSound, registerSound, unregisterSound } from '../sounds';
8 8
 
9 9
 import {
10 10
     localParticipantIdChanged,
11 11
     localParticipantJoined,
12
+    participantLeft,
12 13
     participantUpdated
13 14
 } from './actions';
14 15
 import {
@@ -124,6 +125,26 @@ MiddlewareRegistry.register(store => next => action => {
124 125
     return next(action);
125 126
 });
126 127
 
128
+/**
129
+ * Syncs the redux state features/base/participants up with the redux state
130
+ * features/base/conference by ensuring that the former does not contain remote
131
+ * participants no longer relevant to the latter. Introduced to address an issue
132
+ * with multiplying thumbnails in the filmstrip.
133
+ */
134
+StateListenerRegistry.register(
135
+    /* selector */ state => {
136
+        const { conference, joining } = state['features/base/conference'];
137
+
138
+        return conference || joining;
139
+    },
140
+    /* listener */ (conference, { dispatch, getState }) => {
141
+        for (const p of getState()['features/base/participants']) {
142
+            !p.local
143
+                && (!conference || p.conference !== conference)
144
+                && dispatch(participantLeft(p.id, p.conference));
145
+        }
146
+    });
147
+
127 148
 /**
128 149
  * Initializes the local participant and signals that it joined.
129 150
  *

Loading…
Cancel
Save