Associate remote participant w/ JitsiConference (_LEFT)

The commit message of "Associate remote participant w/ JitsiConference
(_JOINED)" explains the motivation for this commit.
This commit is contained in:
Lyubo Marinov 2018-05-22 16:08:35 -05:00
parent 983e62ffe9
commit 37cd5bb5b9
5 changed files with 37 additions and 7 deletions

View File

@ -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());

View File

@ -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;

View File

@ -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)));

View File

@ -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
}
};

View File

@ -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;