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.
This commit is contained in:
Leonard Kim 2017-04-10 14:53:30 -07:00 committed by Lyubo Marinov
parent c34e841710
commit a82bc1df64
2 changed files with 28 additions and 8 deletions

View File

@ -37,6 +37,7 @@ import {
isFatalJitsiConnectionError isFatalJitsiConnectionError
} from './react/features/base/lib-jitsi-meet'; } from './react/features/base/lib-jitsi-meet';
import { import {
localParticipantRoleChanged,
participantJoined, participantJoined,
participantLeft, participantLeft,
participantRoleChanged, participantRoleChanged,
@ -1262,14 +1263,18 @@ export default {
room.on(ConferenceEvents.USER_ROLE_CHANGED, (id, role) => { room.on(ConferenceEvents.USER_ROLE_CHANGED, (id, role) => {
APP.store.dispatch(participantRoleChanged(id, role));
if (this.isLocalId(id)) { if (this.isLocalId(id)) {
logger.info(`My role changed, new role: ${role}`); logger.info(`My role changed, new role: ${role}`);
APP.store.dispatch(localParticipantRoleChanged(role));
if (this.isModerator !== room.isModerator()) { if (this.isModerator !== room.isModerator()) {
this.isModerator = room.isModerator(); this.isModerator = room.isModerator();
APP.UI.updateLocalRole(room.isModerator()); APP.UI.updateLocalRole(room.isModerator());
} }
} else { } else {
APP.store.dispatch(participantRoleChanged(id, role));
let user = room.getParticipantById(id); let user = room.getParticipantById(id);
if (user) { if (user) {
APP.UI.updateUserRole(user); APP.UI.updateUserRole(user);

View File

@ -29,15 +29,12 @@ export function dominantSpeakerChanged(id) {
} }
/** /**
* Action to signal that ID of local participant has changed. This happens when * Action to signal that the ID of local participant has changed. It happens
* local participant joins a new conference or quits one. * when the local participant joins a new conference or leaves an existing
* conference.
* *
* @param {string} id - New ID for local participant. * @param {string} id - New ID for local participant.
* @returns {{ * @returns {Function}
* type: PARTICIPANT_ID_CHANGED,
* newValue: string,
* oldValue: string
* }}
*/ */
export function localParticipantIdChanged(id) { export function localParticipantIdChanged(id) {
return (dispatch, getState) => { 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. * Action to update a participant's connection status.
* *