From a82bc1df64bfe9132bf0629c81bd18e7b441dc17 Mon Sep 17 00:00:00 2001 From: Leonard Kim Date: Mon, 10 Apr 2017 14:53:30 -0700 Subject: [PATCH] fix: honor updates of the local user role before conference join When the prosody setting has muc_allowners, everyone joins as a moderator. In this case, the local user will not be set as a moderator in the redux store as the USER_ROLE_CHANGE event will trigger with the local user id before the redux store has set the actual local user id--something that happens on CONFERENCE_JOINED. The fix is to explicitly signal the local user role has changed to the redux store, which follows the implementation of pre-existing web logic. --- conference.js | 7 ++++- react/features/base/participants/actions.js | 29 ++++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/conference.js b/conference.js index dee5fc887..9f0152443 100644 --- a/conference.js +++ b/conference.js @@ -37,6 +37,7 @@ import { isFatalJitsiConnectionError } from './react/features/base/lib-jitsi-meet'; import { + localParticipantRoleChanged, participantJoined, participantLeft, participantRoleChanged, @@ -1262,14 +1263,18 @@ export default { room.on(ConferenceEvents.USER_ROLE_CHANGED, (id, role) => { - APP.store.dispatch(participantRoleChanged(id, role)); if (this.isLocalId(id)) { logger.info(`My role changed, new role: ${role}`); + + APP.store.dispatch(localParticipantRoleChanged(role)); + if (this.isModerator !== room.isModerator()) { this.isModerator = room.isModerator(); APP.UI.updateLocalRole(room.isModerator()); } } else { + APP.store.dispatch(participantRoleChanged(id, role)); + let user = room.getParticipantById(id); if (user) { APP.UI.updateUserRole(user); diff --git a/react/features/base/participants/actions.js b/react/features/base/participants/actions.js index d1ffab636..79661af65 100644 --- a/react/features/base/participants/actions.js +++ b/react/features/base/participants/actions.js @@ -29,15 +29,12 @@ export function dominantSpeakerChanged(id) { } /** - * Action to signal that ID of local participant has changed. This happens when - * local participant joins a new conference or quits one. + * Action to signal that the ID of local participant has changed. It happens + * when the local participant joins a new conference or leaves an existing + * conference. * * @param {string} id - New ID for local participant. - * @returns {{ - * type: PARTICIPANT_ID_CHANGED, - * newValue: string, - * oldValue: string - * }} + * @returns {Function} */ export function localParticipantIdChanged(id) { return (dispatch, getState) => { @@ -69,6 +66,24 @@ export function localParticipantJoined(participant = {}) { }); } +/** + * Action to signal the role of the local participant has changed. It can happen + * when the participant has joined a conference, even before a non-default local + * id has been set, or after a moderator leaves. + * + * @param {string} role - The new role of the local participant. + * @returns {Function} + */ +export function localParticipantRoleChanged(role) { + return (dispatch, getState) => { + const participant = getLocalParticipant(getState); + + if (participant) { + return dispatch(participantRoleChanged(participant.id, role)); + } + }; +} + /** * Action to update a participant's connection status. *