From c672ffd435200790d24f55461998d02a39eb49b1 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Sun, 27 May 2018 15:42:13 -0500 Subject: [PATCH] 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. --- .../features/base/participants/actionTypes.js | 1 + react/features/base/participants/actions.js | 4 ++++ react/features/base/participants/reducer.js | 20 +++++++++++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/react/features/base/participants/actionTypes.js b/react/features/base/participants/actionTypes.js index 189fb0f37..533727c51 100644 --- a/react/features/base/participants/actionTypes.js +++ b/react/features/base/participants/actionTypes.js @@ -48,6 +48,7 @@ export const PARTICIPANT_DISPLAY_NAME_CHANGED * * { * type: PARTICIPANT_ID_CHANGED, + * conference: JitsiConference * newValue: string, * oldValue: string * } diff --git a/react/features/base/participants/actions.js b/react/features/base/participants/actions.js index a0b5b92a5..137a4646d 100644 --- a/react/features/base/participants/actions.js +++ b/react/features/base/participants/actions.js @@ -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 }); diff --git a/react/features/base/participants/reducer.js b/react/features/base/participants/reducer.js index cd7217479..9dc2f0ff8 100644 --- a/react/features/base/participants/reducer.js +++ b/react/features/base/participants/reducer.js @@ -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