From 0bd45a75d2d8dcf1f8646509a8ad288463430ee1 Mon Sep 17 00:00:00 2001 From: tmoldovan8x8 <62697631+tmoldovan8x8@users.noreply.github.com> Date: Wed, 16 Jun 2021 14:08:18 +0300 Subject: [PATCH] feat(replace-participant): Add replaceParticipant feature-flag --- conference.js | 6 +++--- modules/UI/authentication/AuthHandler.js | 4 ++-- react/features/base/conference/actions.js | 8 +++++--- react/features/base/config/functions.native.js | 12 ++++++++++++ react/features/base/config/functions.web.js | 10 ++++++++++ react/features/base/flags/constants.js | 6 ++++++ 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/conference.js b/conference.js index 27bea0ab6..d1f70e4e1 100644 --- a/conference.js +++ b/conference.js @@ -45,6 +45,7 @@ import { p2pStatusChanged, sendLocalParticipant } from './react/features/base/conference'; +import { getReplaceParticipant } from './react/features/base/config/functions'; import { checkAndNotifyForNewDevice, getAvailableDevices, @@ -304,9 +305,8 @@ class ConferenceConnector { // not enough rights to create conference case JitsiConferenceErrors.AUTHENTICATION_REQUIRED: { - const { replaceParticipant } - = APP.store.getState()['features/base/config']; + const replaceParticipant = getReplaceParticipant(APP.store.getState()); // Schedule reconnect to check if someone else created the room. this.reconnectTimeout = setTimeout(() => { @@ -397,7 +397,7 @@ class ConferenceConnector { * */ connect() { - const { replaceParticipant } = APP.store.getState()['features/base/config']; + const replaceParticipant = getReplaceParticipant(APP.store.getState()); // the local storage overrides here and in connection.js can be used by jibri room.join(jitsiLocalStorage.getItem('xmpp_conference_password_override'), replaceParticipant); diff --git a/modules/UI/authentication/AuthHandler.js b/modules/UI/authentication/AuthHandler.js index 24c1de694..e459184cf 100644 --- a/modules/UI/authentication/AuthHandler.js +++ b/modules/UI/authentication/AuthHandler.js @@ -11,6 +11,7 @@ import { isTokenAuthEnabled, getTokenAuthUrl } from '../../../react/features/authentication/functions'; +import { getReplaceParticipant } from '../../../react/features/base/config/functions'; import { isDialogOpen } from '../../../react/features/base/dialog'; import { setJWT } from '../../../react/features/base/jwt'; import UIUtil from '../util/UIUtil'; @@ -209,8 +210,7 @@ function logout(room: Object) { }).then(url => { // de-authenticate conference on the fly if (room.isJoined()) { - const { replaceParticipant } - = APP.store.getState()['features/base/config']; + const replaceParticipant = getReplaceParticipant(APP.store.getState()); room.join(null, replaceParticipant); } diff --git a/react/features/base/conference/actions.js b/react/features/base/conference/actions.js index 8d7eb3c1c..711e646a9 100644 --- a/react/features/base/conference/actions.js +++ b/react/features/base/conference/actions.js @@ -8,6 +8,7 @@ import { } from '../../analytics'; import { getName } from '../../app/functions'; import { endpointMessageReceived } from '../../subtitles'; +import { getReplaceParticipant } from '../config/functions'; import { JITSI_CONNECTION_CONFERENCE_KEY } from '../connection'; import { JitsiConferenceEvents } from '../lib-jitsi-meet'; import { MEDIA_TYPE, setAudioMuted, setVideoMuted } from '../media'; @@ -460,7 +461,9 @@ export function createConference() { sendLocalParticipant(state, conference); - conference.join(password, config.replaceParticipant); + const replaceParticipant = getReplaceParticipant(state); + + conference.join(password, replaceParticipant); }; } @@ -477,8 +480,7 @@ export function checkIfCanJoin() { const { authRequired, password } = getState()['features/base/conference']; - const { replaceParticipant } - = getState()['features/base/config']; + const replaceParticipant = getReplaceParticipant(APP.store.getState()); authRequired && dispatch(_conferenceWillJoin(authRequired)); authRequired && authRequired.join(password, replaceParticipant); diff --git a/react/features/base/config/functions.native.js b/react/features/base/config/functions.native.js index 8f17a5d45..8b785fb33 100644 --- a/react/features/base/config/functions.native.js +++ b/react/features/base/config/functions.native.js @@ -2,6 +2,8 @@ import { NativeModules } from 'react-native'; +import { getFeatureFlag, REPLACE_PARTICIPANT } from '../flags'; + export * from './functions.any'; /** @@ -19,3 +21,13 @@ export function _cleanupConfig(config: Object) { delete config.callStatsSecret; } } + +/** + * Returns the replaceParticipant config. + * + * @param {Object} state - The state of the app. + * @returns {boolean} + */ +export function getReplaceParticipant(state: Object): string { + return getFeatureFlag(state, REPLACE_PARTICIPANT, false); +} diff --git a/react/features/base/config/functions.web.js b/react/features/base/config/functions.web.js index f411373c9..224d4f5b0 100644 --- a/react/features/base/config/functions.web.js +++ b/react/features/base/config/functions.web.js @@ -33,6 +33,16 @@ export function getDialOutUrl(state: Object): string { return state['features/base/config'].guestDialOutUrl; } +/** + * Returns the replaceParticipant config. + * + * @param {Object} state - The state of the app. + * @returns {boolean} + */ +export function getReplaceParticipant(state: Object): string { + return state['features/base/config'].replaceParticipant; +} + /** * Returns the list of enabled toolbar buttons. * diff --git a/react/features/base/flags/constants.js b/react/features/base/flags/constants.js index 8e6deba52..692b27d8e 100644 --- a/react/features/base/flags/constants.js +++ b/react/features/base/flags/constants.js @@ -154,6 +154,12 @@ export const RAISE_HAND_ENABLED = 'raise-hand.enabled'; */ export const RECORDING_ENABLED = 'recording.enabled'; +/** + * Flag indicating if the user should join the conference with the replaceParticipant functionality. + * Default: (false). + */ +export const REPLACE_PARTICIPANT = 'replace.participant'; + /** * Flag indicating the local and (maximum) remote video resolution. Overrides * the server configuration.