Skip to content

Commit

Permalink
Refine PARTICIPANT_LEFT for ID collisions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lyubomir authored and saghul committed May 29, 2018
1 parent 8cfc83f commit c672ffd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions react/features/base/participants/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const PARTICIPANT_DISPLAY_NAME_CHANGED
*
* {
* type: PARTICIPANT_ID_CHANGED,
* conference: JitsiConference
* newValue: string,
* oldValue: string
* }
Expand Down
4 changes: 4 additions & 0 deletions react/features/base/participants/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down
20 changes: 16 additions & 4 deletions react/features/base/participants/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}

Expand All @@ -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
Expand Down

0 comments on commit c672ffd

Please sign in to comment.