Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Associate remote participant w/ JitsiConference (_LEFT)

Lyubo Marinov37cd5bb5b9a6
diff --git a/conference.js b/conference.js
index 76a729eaa3..f30cf0ff56 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 c29e23015a..c43bcc216a 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 5cae20a97c..b07714fac7 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 a67f4ca206..b08cafeb9b 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 5af3dc33a2..260432e52a 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;