From 37cd5bb5b9a61d0d15f60ba0c7bec03db8a50330 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Tue, 22 May 2018 16:08:35 -0500 Subject: [PATCH] Associate remote participant w/ JitsiConference (_LEFT) The commit message of "Associate remote participant w/ JitsiConference (_JOINED)" explains the motivation for this commit. --- conference.js | 2 +- modules/UI/shared_video/SharedVideo.js | 2 +- react/features/base/conference/actions.js | 2 +- react/features/base/participants/actions.js | 22 +++++++++++++++++++-- react/features/base/participants/reducer.js | 16 +++++++++++++-- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/conference.js b/conference.js index 76a729eaa..f30cf0ff5 100644 --- a/conference.js +++ b/conference.js @@ -1710,7 +1710,7 @@ export default { if (user.isHidden()) { return; } - APP.store.dispatch(participantLeft(id, user)); + APP.store.dispatch(participantLeft(id, room)); logger.log('USER %s LEFT', id, user); APP.API.notifyUserLeft(id); APP.UI.removeUser(id, user.getDisplayName()); diff --git a/modules/UI/shared_video/SharedVideo.js b/modules/UI/shared_video/SharedVideo.js index c29e23015..c43bcc216 100644 --- a/modules/UI/shared_video/SharedVideo.js +++ b/modules/UI/shared_video/SharedVideo.js @@ -517,7 +517,7 @@ export default class SharedVideoManager { UIEvents.UPDATE_SHARED_VIDEO, null, 'removed'); }); - APP.store.dispatch(participantLeft(this.url)); + APP.store.dispatch(participantLeft(this.url, APP.conference)); this.url = null; this.isSharedVideoShown = false; diff --git a/react/features/base/conference/actions.js b/react/features/base/conference/actions.js index 5cae20a97..b07714fac 100644 --- a/react/features/base/conference/actions.js +++ b/react/features/base/conference/actions.js @@ -147,7 +147,7 @@ function _addConferenceListeners(conference, dispatch) { }))); conference.on( JitsiConferenceEvents.USER_LEFT, - (...args) => dispatch(participantLeft(...args))); + id => dispatch(participantLeft(id, conference))); conference.on( JitsiConferenceEvents.USER_ROLE_CHANGED, (...args) => dispatch(participantRoleChanged(...args))); diff --git a/react/features/base/participants/actions.js b/react/features/base/participants/actions.js index a67f4ca20..b08cafeb9 100644 --- a/react/features/base/participants/actions.js +++ b/react/features/base/participants/actions.js @@ -123,7 +123,19 @@ export function localParticipantLeft() { const participant = getLocalParticipant(getState); if (participant) { - return dispatch(participantLeft(participant.id)); + return ( + dispatch( + participantLeft( + participant.id, + + // XXX Only the local participant is allowed to leave + // without stating the JitsiConference instance because + // the local participant is uniquely identified by the + // very fact that there is only one local participant + // (and the fact that the local participant "joins" at + // the beginning of the app and "leaves" at the end of + // the app). + undefined))); } }; } @@ -234,17 +246,23 @@ export function participantJoined(participant) { * Action to signal that a participant has left. * * @param {string} id - Participant's ID. + * @param {JitsiConference} conference - The {@code JitsiConference} associated + * with the participant identified by the specified {@code id}. Only the local + * participant is allowed to not specify an associated {@code JitsiConference} + * instance. * @returns {{ * type: PARTICIPANT_LEFT, * participant: { + * conference: JitsiConference, * id: string * } * }} */ -export function participantLeft(id) { +export function participantLeft(id, conference) { return { type: PARTICIPANT_LEFT, participant: { + conference, id } }; diff --git a/react/features/base/participants/reducer.js b/react/features/base/participants/reducer.js index 5af3dc33a..260432e52 100644 --- a/react/features/base/participants/reducer.js +++ b/react/features/base/participants/reducer.js @@ -61,8 +61,20 @@ ReducerRegistry.register('features/base/participants', (state = [], action) => { case PARTICIPANT_JOINED: return [ ...state, _participantJoined(action) ]; - case PARTICIPANT_LEFT: - return state.filter(p => p.id !== action.participant.id); + case PARTICIPANT_LEFT: { + // XXX A remote participant is uniquely identified by their id in a + // specific JitsiConference instance. The local participant is uniquely + // identified by the very fact that there is only one local participant + // (and the fact that the local participant "joins" at the beginning of + // the app and "leaves" at the end of the app). + const { conference, id } = action.participant; + + return state.filter(p => + !( + p.id === id + && (p.local + || (conference && p.conference === conference)))); + } } return state;