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.
This commit is contained in:
Lyubo Marinov 2018-05-21 22:48:51 -05:00
parent db21e97c19
commit ee9fcbb735
1 changed files with 22 additions and 1 deletions

View File

@ -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.
*