Refine PARTICIPANT_LEFT for ID collisions

If the ID of a remote participant was the same as the ID of the local
participant (across multiple conferences), removing the remote
participant on PARTICIPANT_LEFT would remove the local participant.

Like the preceding commit "ref(base/conference): clear the 'conference'
field on WILL_LEAVE", this commit is part of the story how we are to
deal with conferences which take noticeable time to leave.
This commit is contained in:
Lyubo Marinov 2018-05-27 15:42:13 -05:00 committed by Saúl Ibarra Corretgé
parent 8cfc83f18c
commit c672ffd435
3 changed files with 21 additions and 4 deletions

View File

@ -48,6 +48,7 @@ export const PARTICIPANT_DISPLAY_NAME_CHANGED
*
* {
* type: PARTICIPANT_ID_CHANGED,
* conference: JitsiConference
* newValue: string,
* oldValue: string
* }

View File

@ -97,6 +97,10 @@ export function localParticipantIdChanged(id) {
if (participant) {
return dispatch({
type: PARTICIPANT_ID_CHANGED,
// XXX A participant is identified by an id-conference pair.
// Only the local participant is with an undefined conference.
conference: undefined,
newValue: id,
oldValue: participant.id
});

View File

@ -84,8 +84,13 @@ ReducerRegistry.register('features/base/participants', (state = [], action) => {
return state.filter(p =>
!(
p.id === id
&& (p.local
|| (conference && p.conference === conference))));
// XXX Do not allow collisions in the IDs of the local
// participant and a remote participant cause the removal of
// the local participant when the remote participant's
// removal is requested.
&& p.conference === conference
&& (conference || p.local)));
}
}
@ -111,14 +116,21 @@ function _participant(state: Object = {}, action) {
return (
set(state, 'dominantSpeaker', state.id === action.participant.id));
case PARTICIPANT_ID_CHANGED:
if (state.id === action.oldValue) {
case PARTICIPANT_ID_CHANGED: {
// A participant is identified by an id-conference pair. Only the local
// participant is with an undefined conference.
const { conference } = action;
if (state.id === action.oldValue
&& state.conference === conference
&& (conference || state.local)) {
return {
...state,
id: action.newValue
};
}
break;
}
case PARTICIPANT_UPDATED: {
const { participant } = action; // eslint-disable-line no-shadow