From 97310b5ab55cff807bb2cb3bc4bd4c6bd136021f Mon Sep 17 00:00:00 2001 From: damencho Date: Thu, 21 Nov 2024 17:17:53 -0600 Subject: [PATCH] fix(iframeAPI): Fix role changed event to work not only for local user. --- react/features/base/participants/actions.ts | 31 +++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/react/features/base/participants/actions.ts b/react/features/base/participants/actions.ts index f9c041aff730..707b6356d9fd 100644 --- a/react/features/base/participants/actions.ts +++ b/react/features/base/participants/actions.ts @@ -17,6 +17,7 @@ import { PARTICIPANT_JOINED, PARTICIPANT_KICKED, PARTICIPANT_LEFT, + PARTICIPANT_ROLE_CHANGED, PARTICIPANT_SOURCES_UPDATED, PARTICIPANT_UPDATED, PIN_PARTICIPANT, @@ -389,19 +390,27 @@ export function participantPresenceChanged(id: string, presence: string) { * * @param {string} id - Participant's ID. * @param {PARTICIPANT_ROLE} role - Participant's new role. - * @returns {{ - * type: PARTICIPANT_UPDATED, - * participant: { - * id: string, - * role: PARTICIPANT_ROLE - * } - * }} + * @returns {Promise} */ export function participantRoleChanged(id: string, role: string) { - return participantUpdated({ - id, - role - }); + return (dispatch: IStore['dispatch'], getState: IStore['getState']) => { + const oldParticipantRole = getParticipantById(getState(), id)?.role; + + dispatch(participantUpdated({ + id, + role + })); + + if (oldParticipantRole !== role) { + dispatch({ + type: PARTICIPANT_ROLE_CHANGED, + participant: { + id, + role + } + }); + } + }; } /**