2022-10-21 07:33:10 +00:00
|
|
|
import { IReduxState } from '../app/types';
|
|
|
|
import { IStateful } from '../base/app/types';
|
|
|
|
import { isNameReadOnly } from '../base/config/functions';
|
|
|
|
import { SERVER_URL_CHANGE_ENABLED } from '../base/flags/constants';
|
|
|
|
import { getFeatureFlag } from '../base/flags/functions';
|
|
|
|
import i18next, { DEFAULT_LANGUAGE, LANGUAGES } from '../base/i18n/i18next';
|
2019-05-30 21:10:40 +00:00
|
|
|
import {
|
|
|
|
getLocalParticipant,
|
|
|
|
isLocalParticipantModerator
|
2022-10-21 07:33:10 +00:00
|
|
|
} from '../base/participants/functions';
|
|
|
|
import { toState } from '../base/redux/functions';
|
|
|
|
import { getHideSelfView } from '../base/settings/functions';
|
|
|
|
import { parseStandardURIString } from '../base/util/uri';
|
2022-05-05 09:20:20 +00:00
|
|
|
import { isStageFilmstripEnabled } from '../filmstrip/functions';
|
2022-11-28 10:52:45 +00:00
|
|
|
import { isFollowMeActive } from '../follow-me/functions';
|
2022-05-19 08:48:54 +00:00
|
|
|
import { getParticipantsPaneConfig } from '../participants-pane/functions';
|
2021-09-21 17:30:24 +00:00
|
|
|
import { isReactionsEnabled } from '../reactions/functions.any';
|
2018-01-26 10:19:43 +00:00
|
|
|
|
2021-06-28 07:48:16 +00:00
|
|
|
import { SS_DEFAULT_FRAME_RATE, SS_SUPPORTED_FRAMERATES } from './constants';
|
|
|
|
|
2018-04-28 01:43:11 +00:00
|
|
|
/**
|
|
|
|
* Used for web. Indicates if the setting section is enabled.
|
|
|
|
*
|
|
|
|
* @param {string} settingName - The name of the setting section as defined in
|
|
|
|
* interface_config.js and SettingsMenu.js.
|
|
|
|
* @returns {boolean} True to indicate that the given setting section
|
|
|
|
* is enabled, false otherwise.
|
|
|
|
*/
|
|
|
|
export function isSettingEnabled(settingName: string) {
|
|
|
|
return interfaceConfig.SETTINGS_SECTIONS.includes(settingName);
|
|
|
|
}
|
|
|
|
|
2020-06-26 09:47:48 +00:00
|
|
|
/**
|
|
|
|
* Returns true if user is allowed to change Server URL.
|
|
|
|
*
|
|
|
|
* @param {(Function|Object)} stateful - The (whole) redux state, or redux's
|
|
|
|
* {@code getState} function to be used to retrieve the state.
|
|
|
|
* @returns {boolean} True to indicate that user can change Server URL, false otherwise.
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function isServerURLChangeEnabled(stateful: IStateful) {
|
2020-06-26 09:47:48 +00:00
|
|
|
const state = toState(stateful);
|
|
|
|
const flag = getFeatureFlag(state, SERVER_URL_CHANGE_ENABLED, true);
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2018-01-26 10:19:43 +00:00
|
|
|
/**
|
|
|
|
* Normalizes a URL entered by the user.
|
|
|
|
* FIXME: Consider adding this to base/util/uri.
|
|
|
|
*
|
|
|
|
* @param {string} url - The URL to validate.
|
|
|
|
* @returns {string|null} - The normalized URL, or null if the URL is invalid.
|
|
|
|
*/
|
|
|
|
export function normalizeUserInputURL(url: string) {
|
|
|
|
/* eslint-disable no-param-reassign */
|
|
|
|
|
|
|
|
if (url) {
|
|
|
|
url = url.replace(/\s/g, '').toLowerCase();
|
2018-02-26 16:14:46 +00:00
|
|
|
|
2018-01-26 10:19:43 +00:00
|
|
|
const urlRegExp = new RegExp('^(\\w+://)?(.+)$');
|
|
|
|
const urlComponents = urlRegExp.exec(url);
|
|
|
|
|
2018-10-03 09:29:19 +00:00
|
|
|
if (urlComponents && (!urlComponents[1]
|
|
|
|
|| !urlComponents[1].startsWith('http'))) {
|
2018-01-26 10:19:43 +00:00
|
|
|
url = `https://${urlComponents[2]}`;
|
|
|
|
}
|
|
|
|
|
2018-02-26 16:14:46 +00:00
|
|
|
const parsedURI = parseStandardURIString(url);
|
2018-01-26 10:19:43 +00:00
|
|
|
|
|
|
|
if (!parsedURI.host) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parsedURI.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
return url;
|
|
|
|
|
|
|
|
/* eslint-enable no-param-reassign */
|
|
|
|
}
|
2018-04-28 01:43:11 +00:00
|
|
|
|
2021-12-17 12:39:15 +00:00
|
|
|
/**
|
|
|
|
* Returns the notification types and their user selected configuration.
|
|
|
|
*
|
|
|
|
* @param {(Function|Object)} stateful -The (whole) redux state, or redux's
|
|
|
|
* {@code getState} function to be used to retrieve the state.
|
|
|
|
* @returns {Object} - The section of notifications to be configured.
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function getNotificationsMap(stateful: IStateful) {
|
2021-12-17 12:39:15 +00:00
|
|
|
const state = toState(stateful);
|
|
|
|
const { notifications } = state['features/base/config'];
|
|
|
|
const { userSelectedNotifications } = state['features/base/settings'];
|
|
|
|
|
2022-10-21 07:33:10 +00:00
|
|
|
if (!userSelectedNotifications) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2021-12-17 12:39:15 +00:00
|
|
|
return Object.keys(userSelectedNotifications)
|
|
|
|
.filter(key => !notifications || notifications.includes(key))
|
|
|
|
.reduce((notificationsMap, key) => {
|
|
|
|
return {
|
|
|
|
...notificationsMap,
|
|
|
|
[key]: userSelectedNotifications[key]
|
|
|
|
};
|
|
|
|
}, {});
|
|
|
|
}
|
|
|
|
|
2018-04-28 01:43:11 +00:00
|
|
|
/**
|
2021-11-10 11:19:40 +00:00
|
|
|
* Returns the properties for the "More" tab from settings dialog from Redux
|
|
|
|
* state.
|
2018-04-28 01:43:11 +00:00
|
|
|
*
|
2021-11-10 11:19:40 +00:00
|
|
|
* @param {(Function|Object)} stateful -The (whole) redux state, or redux's
|
|
|
|
* {@code getState} function to be used to retrieve the state.
|
|
|
|
* @returns {Object} - The properties for the "More" tab from settings dialog.
|
2018-04-28 01:43:11 +00:00
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function getMoreTabProps(stateful: IStateful) {
|
2021-11-10 11:19:40 +00:00
|
|
|
const state = toState(stateful);
|
|
|
|
const framerate = state['features/screen-share'].captureFrameRate ?? SS_DEFAULT_FRAME_RATE;
|
2021-12-17 12:39:15 +00:00
|
|
|
const enabledNotifications = getNotificationsMap(stateful);
|
2022-05-05 09:20:20 +00:00
|
|
|
const stageFilmstripEnabled = isStageFilmstripEnabled(state);
|
2021-11-10 11:19:40 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
currentFramerate: framerate,
|
|
|
|
desktopShareFramerates: SS_SUPPORTED_FRAMERATES,
|
2021-12-17 12:39:15 +00:00
|
|
|
enabledNotifications,
|
|
|
|
showNotificationsSettings: Object.keys(enabledNotifications).length > 0,
|
2021-11-10 11:19:40 +00:00
|
|
|
showPrejoinPage: !state['features/base/settings'].userSelectedSkipPrejoin,
|
2022-04-07 08:31:53 +00:00
|
|
|
showPrejoinSettings: state['features/base/config'].prejoinConfig?.enabled,
|
2022-09-15 07:57:48 +00:00
|
|
|
maxStageParticipants: state['features/base/settings'].maxStageParticipants,
|
2022-05-05 09:20:20 +00:00
|
|
|
stageFilmstripEnabled
|
2021-11-10 11:19:40 +00:00
|
|
|
};
|
2018-04-28 01:43:11 +00:00
|
|
|
}
|
2018-06-20 20:19:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the properties for the "More" tab from settings dialog from Redux
|
|
|
|
* state.
|
|
|
|
*
|
|
|
|
* @param {(Function|Object)} stateful -The (whole) redux state, or redux's
|
|
|
|
* {@code getState} function to be used to retrieve the state.
|
|
|
|
* @returns {Object} - The properties for the "More" tab from settings dialog.
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function getModeratorTabProps(stateful: IStateful) {
|
2018-06-20 20:19:53 +00:00
|
|
|
const state = toState(stateful);
|
2018-08-06 15:24:59 +00:00
|
|
|
const {
|
|
|
|
conference,
|
|
|
|
followMeEnabled,
|
|
|
|
startAudioMutedPolicy,
|
2021-11-10 11:19:40 +00:00
|
|
|
startVideoMutedPolicy,
|
|
|
|
startReactionsMuted
|
2018-08-06 15:24:59 +00:00
|
|
|
} = state['features/base/conference'];
|
2021-12-13 19:46:05 +00:00
|
|
|
const { disableReactionsModeration } = state['features/base/config'];
|
2020-04-30 21:25:34 +00:00
|
|
|
const followMeActive = isFollowMeActive(state);
|
2022-01-27 08:22:26 +00:00
|
|
|
const showModeratorSettings = shouldShowModeratorSettings(state);
|
2018-06-20 20:19:53 +00:00
|
|
|
|
2021-11-10 11:19:40 +00:00
|
|
|
// The settings sections to display.
|
2018-06-20 20:19:53 +00:00
|
|
|
return {
|
2022-01-27 08:22:26 +00:00
|
|
|
showModeratorSettings: Boolean(conference && showModeratorSettings),
|
2021-12-13 19:46:05 +00:00
|
|
|
disableReactionsModeration: Boolean(disableReactionsModeration),
|
2019-04-26 18:11:53 +00:00
|
|
|
followMeActive: Boolean(conference && followMeActive),
|
2018-08-06 15:24:59 +00:00
|
|
|
followMeEnabled: Boolean(conference && followMeEnabled),
|
2021-11-10 11:19:40 +00:00
|
|
|
startReactionsMuted: Boolean(conference && startReactionsMuted),
|
2018-08-06 15:24:59 +00:00
|
|
|
startAudioMuted: Boolean(conference && startAudioMutedPolicy),
|
|
|
|
startVideoMuted: Boolean(conference && startVideoMutedPolicy)
|
2018-06-20 20:19:53 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-01-27 08:22:26 +00:00
|
|
|
/**
|
|
|
|
* Returns true if moderator tab in settings should be visible/accessible.
|
|
|
|
*
|
|
|
|
* @param {(Function|Object)} stateful - The (whole) redux state, or redux's
|
|
|
|
* {@code getState} function to be used to retrieve the state.
|
|
|
|
* @returns {boolean} True to indicate that moderator tab should be visible, false otherwise.
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function shouldShowModeratorSettings(stateful: IStateful) {
|
2022-01-27 08:22:26 +00:00
|
|
|
const state = toState(stateful);
|
2022-05-19 08:48:54 +00:00
|
|
|
const { hideModeratorSettingsTab } = getParticipantsPaneConfig(state);
|
|
|
|
const hasModeratorRights = Boolean(isSettingEnabled('moderator') && isLocalParticipantModerator(state));
|
|
|
|
|
|
|
|
return hasModeratorRights && !hideModeratorSettingsTab;
|
2022-01-27 08:22:26 +00:00
|
|
|
}
|
|
|
|
|
2018-06-20 20:19:53 +00:00
|
|
|
/**
|
|
|
|
* Returns the properties for the "Profile" tab from settings dialog from Redux
|
|
|
|
* state.
|
|
|
|
*
|
|
|
|
* @param {(Function|Object)} stateful -The (whole) redux state, or redux's
|
|
|
|
* {@code getState} function to be used to retrieve the state.
|
|
|
|
* @returns {Object} - The properties for the "Profile" tab from settings
|
|
|
|
* dialog.
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function getProfileTabProps(stateful: IStateful) {
|
2018-06-20 20:19:53 +00:00
|
|
|
const state = toState(stateful);
|
2018-08-06 15:24:59 +00:00
|
|
|
const {
|
|
|
|
authEnabled,
|
|
|
|
authLogin,
|
|
|
|
conference
|
|
|
|
} = state['features/base/conference'];
|
2021-12-13 15:17:38 +00:00
|
|
|
const { hideEmailInSettings } = state['features/base/config'];
|
2018-06-20 20:19:53 +00:00
|
|
|
const localParticipant = getLocalParticipant(state);
|
2023-03-03 08:42:59 +00:00
|
|
|
const language = i18next.language || DEFAULT_LANGUAGE;
|
|
|
|
const configuredTabs: string[] = interfaceConfig.SETTINGS_SECTIONS || [];
|
|
|
|
|
|
|
|
// when self view is controlled by the config we hide the settings
|
|
|
|
const { disableSelfView, disableSelfViewSettings } = state['features/base/config'];
|
2018-06-20 20:19:53 +00:00
|
|
|
|
|
|
|
return {
|
2018-08-06 15:24:59 +00:00
|
|
|
authEnabled: Boolean(conference && authEnabled),
|
2019-03-19 20:44:37 +00:00
|
|
|
authLogin,
|
2023-03-03 08:42:59 +00:00
|
|
|
disableHideSelfView: disableSelfViewSettings || disableSelfView,
|
|
|
|
currentLanguage: language,
|
2022-10-21 07:33:10 +00:00
|
|
|
displayName: localParticipant?.name,
|
|
|
|
email: localParticipant?.email,
|
2023-03-03 08:42:59 +00:00
|
|
|
hideEmailInSettings,
|
|
|
|
hideSelfView: getHideSelfView(state),
|
|
|
|
id: localParticipant?.id,
|
|
|
|
languages: LANGUAGES,
|
2021-12-13 15:17:38 +00:00
|
|
|
readOnlyName: isNameReadOnly(state),
|
2023-03-03 08:42:59 +00:00
|
|
|
showLanguageSettings: configuredTabs.includes('language')
|
2018-06-20 20:19:53 +00:00
|
|
|
};
|
|
|
|
}
|
2020-03-30 14:17:18 +00:00
|
|
|
|
2021-07-20 11:56:57 +00:00
|
|
|
/**
|
|
|
|
* Returns the properties for the "Sounds" tab from settings dialog from Redux
|
|
|
|
* state.
|
|
|
|
*
|
|
|
|
* @param {(Function|Object)} stateful -The (whole) redux state, or redux's
|
|
|
|
* {@code getState} function to be used to retrieve the state.
|
|
|
|
* @returns {Object} - The properties for the "Sounds" tab from settings
|
|
|
|
* dialog.
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function getSoundsTabProps(stateful: IStateful) {
|
2021-07-20 11:56:57 +00:00
|
|
|
const state = toState(stateful);
|
|
|
|
const {
|
|
|
|
soundsIncomingMessage,
|
|
|
|
soundsParticipantJoined,
|
2022-06-15 18:36:26 +00:00
|
|
|
soundsParticipantKnocking,
|
2021-07-20 11:56:57 +00:00
|
|
|
soundsParticipantLeft,
|
2021-08-23 09:57:56 +00:00
|
|
|
soundsTalkWhileMuted,
|
|
|
|
soundsReactions
|
2021-07-20 11:56:57 +00:00
|
|
|
} = state['features/base/settings'];
|
2021-09-21 17:30:24 +00:00
|
|
|
const enableReactions = isReactionsEnabled(state);
|
2021-11-10 11:19:40 +00:00
|
|
|
const moderatorMutedSoundsReactions = state['features/base/conference'].startReactionsMuted ?? false;
|
2021-07-20 11:56:57 +00:00
|
|
|
|
|
|
|
return {
|
2023-02-28 14:47:00 +00:00
|
|
|
disabledSounds: state['features/base/config'].disabledSounds || [],
|
2021-07-20 11:56:57 +00:00
|
|
|
soundsIncomingMessage,
|
|
|
|
soundsParticipantJoined,
|
2022-06-15 18:36:26 +00:00
|
|
|
soundsParticipantKnocking,
|
2021-07-20 11:56:57 +00:00
|
|
|
soundsParticipantLeft,
|
2021-08-23 09:57:56 +00:00
|
|
|
soundsTalkWhileMuted,
|
|
|
|
soundsReactions,
|
2021-11-10 11:19:40 +00:00
|
|
|
enableReactions,
|
|
|
|
moderatorMutedSoundsReactions
|
2021-07-20 11:56:57 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:17:18 +00:00
|
|
|
/**
|
|
|
|
* Returns the visibility state of the audio settings.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the application.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function getAudioSettingsVisibility(state: IReduxState) {
|
2020-03-30 14:17:18 +00:00
|
|
|
return state['features/settings'].audioSettingsVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the visibility state of the video settings.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the application.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-21 07:33:10 +00:00
|
|
|
export function getVideoSettingsVisibility(state: IReduxState) {
|
2020-03-30 14:17:18 +00:00
|
|
|
return state['features/settings'].videoSettingsVisible;
|
|
|
|
}
|