From ee9fcbb7355dae55821515685ba4b1380d73686b Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Mon, 21 May 2018 22:48:51 -0500 Subject: [PATCH] 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. --- .../features/base/participants/middleware.js | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/react/features/base/participants/middleware.js b/react/features/base/participants/middleware.js index a4c99faf0..ddd7f0a49 100644 --- a/react/features/base/participants/middleware.js +++ b/react/features/base/participants/middleware.js @@ -2,13 +2,14 @@ import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../app'; import { CONFERENCE_LEFT, CONFERENCE_WILL_JOIN } from '../conference'; -import { MiddlewareRegistry } from '../redux'; +import { MiddlewareRegistry, StateListenerRegistry } from '../redux'; import UIEvents from '../../../../service/UI/UIEvents'; import { playSound, registerSound, unregisterSound } from '../sounds'; import { localParticipantIdChanged, localParticipantJoined, + participantLeft, participantUpdated } from './actions'; import { @@ -124,6 +125,26 @@ MiddlewareRegistry.register(store => next => action => { return next(action); }); +/** + * Syncs the redux state features/base/participants up with the redux state + * features/base/conference by ensuring that the former does not contain remote + * participants no longer relevant to the latter. Introduced to address an issue + * with multiplying thumbnails in the filmstrip. + */ +StateListenerRegistry.register( + /* selector */ state => { + const { conference, joining } = state['features/base/conference']; + + return conference || joining; + }, + /* listener */ (conference, { dispatch, getState }) => { + for (const p of getState()['features/base/participants']) { + !p.local + && (!conference || p.conference !== conference) + && dispatch(participantLeft(p.id, p.conference)); + } + }); + /** * Initializes the local participant and signals that it joined. *