ref(api): move participant join and left to middleware (#4365)

This commit is contained in:
virtuacoplenny 2019-07-11 12:44:27 -07:00 committed by GitHub
parent 0a76eebca7
commit 2f626ea474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 10 deletions

View File

@ -1713,14 +1713,7 @@ export default {
return;
}
const displayName = user.getDisplayName();
logger.log(`USER ${id} connnected:`, user);
APP.API.notifyUserJoined(id, {
displayName,
formattedDisplayName: appendSuffix(
displayName || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME)
});
APP.UI.addUser(user);
// check the roles for the new user and reflect them
@ -1736,7 +1729,7 @@ export default {
}
logger.log(`USER ${id} LEFT:`, user);
APP.API.notifyUserLeft(id);
APP.UI.onSharedVideoStop(id);
});

View File

@ -7,7 +7,7 @@
* @param {string} suffix - Suffix that will be appended.
* @returns {string} The formatted display name.
*/
export function appendSuffix(displayName: string, suffix: string) {
return `${displayName || suffix || ''}${
export function appendSuffix(displayName: string, suffix: string = '') {
return `${displayName || suffix}${
displayName && suffix && displayName !== suffix ? ` (${suffix})` : ''}`;
}

View File

@ -9,6 +9,8 @@ import { NOTIFY_CAMERA_ERROR, NOTIFY_MIC_ERROR } from '../base/devices';
import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
import {
PARTICIPANT_KICKED,
PARTICIPANT_LEFT,
PARTICIPANT_JOINED,
SET_LOADABLE_AVATAR_URL,
getLocalParticipant,
getParticipantById
@ -129,6 +131,27 @@ MiddlewareRegistry.register(store => next => action => {
{ id: action.kicker });
break;
case PARTICIPANT_LEFT:
APP.API.notifyUserLeft(action.participant.id);
break;
case PARTICIPANT_JOINED: {
const { participant } = action;
const { id, local, name } = participant;
// The version of external api outside of middleware did not emit
// the local participant being created.
if (!local) {
APP.API.notifyUserJoined(id, {
displayName: name,
formattedDisplayName: appendSuffix(
name || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME)
});
}
break;
}
case SET_FILMSTRIP_VISIBLE:
APP.API.notifyFilmstripDisplayChanged(action.visible);
break;