2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState } from '../app/types';
|
2022-09-23 07:48:20 +00:00
|
|
|
import { getRoomName } from '../base/conference/functions';
|
2022-11-10 08:45:56 +00:00
|
|
|
import { getDialOutStatusUrl, getDialOutUrl } from '../base/config/functions';
|
2022-09-23 07:48:20 +00:00
|
|
|
import { isAudioMuted, isVideoMutedByUser } from '../base/media/functions';
|
2020-04-16 10:47:10 +00:00
|
|
|
|
|
|
|
/**
|
2020-05-19 07:52:57 +00:00
|
|
|
* Selector for the visibility of the 'join by phone' button.
|
2020-04-16 10:47:10 +00:00
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isJoinByPhoneButtonVisible(state: IReduxState): boolean {
|
2020-05-14 12:30:24 +00:00
|
|
|
return Boolean(getDialOutUrl(state) && getDialOutStatusUrl(state));
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selector for determining if the device status strip is visible or not.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isDeviceStatusVisible(state: IReduxState): boolean {
|
2020-06-19 07:03:26 +00:00
|
|
|
return !(isAudioMuted(state) && isVideoMutedByUser(state))
|
|
|
|
&& !state['features/base/config'].startSilent;
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
|
|
|
|
2020-07-02 09:18:38 +00:00
|
|
|
/**
|
|
|
|
* Selector for determining if the display name is mandatory.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-07-02 09:18:38 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isDisplayNameRequired(state: IReduxState): boolean {
|
2022-09-23 07:48:20 +00:00
|
|
|
return Boolean(state['features/prejoin']?.isDisplayNameRequired
|
|
|
|
|| state['features/base/config']?.requireDisplayName);
|
2020-07-02 09:18:38 +00:00
|
|
|
}
|
|
|
|
|
2022-05-26 12:38:38 +00:00
|
|
|
/**
|
|
|
|
* Selector for determining if the prejoin display name field is visible.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2022-05-26 12:38:38 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isPrejoinDisplayNameVisible(state: IReduxState): boolean {
|
2022-05-30 08:20:58 +00:00
|
|
|
return !state['features/base/config'].prejoinConfig?.hideDisplayName;
|
2022-05-26 12:38:38 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
|
|
|
* Returns the text for the prejoin status bar.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function getDeviceStatusText(state: IReduxState): string {
|
2020-05-11 12:06:22 +00:00
|
|
|
return state['features/prejoin']?.deviceStatusText;
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the type of the prejoin status bar: 'ok'|'warning'.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function getDeviceStatusType(state: IReduxState): string {
|
2020-05-11 12:06:22 +00:00
|
|
|
return state['features/prejoin']?.deviceStatusType;
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
|
|
|
|
2020-05-14 12:30:24 +00:00
|
|
|
/**
|
|
|
|
* Returns the 'conferenceUrl' used for dialing out.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-05-14 12:30:24 +00:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function getDialOutConferenceUrl(state: IReduxState): string {
|
2022-09-23 07:48:20 +00:00
|
|
|
return `${getRoomName(state)}@${state['features/base/config'].hosts?.muc}`;
|
2020-05-14 12:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selector for getting the dial out country.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-05-14 12:30:24 +00:00
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function getDialOutCountry(state: IReduxState) {
|
2020-05-14 12:30:24 +00:00
|
|
|
return state['features/prejoin'].dialOutCountry;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selector for getting the dial out number (without prefix).
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-05-14 12:30:24 +00:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function getDialOutNumber(state: IReduxState): string {
|
2020-05-14 12:30:24 +00:00
|
|
|
return state['features/prejoin'].dialOutNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selector for getting the dial out status while calling.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-05-14 12:30:24 +00:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function getDialOutStatus(state: IReduxState): string {
|
2020-05-14 12:30:24 +00:00
|
|
|
return state['features/prejoin'].dialOutStatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the full dial out number (containing country code and +).
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-05-14 12:30:24 +00:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function getFullDialOutNumber(state: IReduxState): string {
|
2020-05-14 12:30:24 +00:00
|
|
|
const dialOutNumber = getDialOutNumber(state);
|
|
|
|
const country = getDialOutCountry(state);
|
|
|
|
|
|
|
|
return `+${country.dialCode}${dialOutNumber}`;
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
|
|
|
* Selector for getting the error if any while creating streams.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function getRawError(state: IReduxState): string {
|
2020-05-11 12:06:22 +00:00
|
|
|
return state['features/prejoin']?.rawError;
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* Selector for getting the visibility state for the 'JoinByPhoneDialog'.
|
2020-04-16 10:47:10 +00:00
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isJoinByPhoneDialogVisible(state: IReduxState): boolean {
|
2020-05-11 12:06:22 +00:00
|
|
|
return state['features/prejoin']?.showJoinByPhoneDialog;
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the prejoin page is enabled and no flag
|
|
|
|
* to bypass showing the page is present.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isPrejoinPageVisible(state: IReduxState): boolean {
|
2022-09-23 07:48:20 +00:00
|
|
|
return Boolean(navigator.product !== 'ReactNative'
|
2021-12-08 07:53:19 +00:00
|
|
|
&& state['features/base/config'].prejoinConfig?.enabled
|
2021-12-20 09:34:40 +00:00
|
|
|
&& state['features/prejoin']?.showPrejoin
|
2022-09-23 07:48:20 +00:00
|
|
|
&& !(state['features/base/config'].enableForcedReload && state['features/prejoin'].skipPrejoinOnReload));
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
|
|
|
|
2021-02-24 09:35:32 +00:00
|
|
|
/**
|
|
|
|
* Returns true if we should auto-knock in case lobby is enabled for the room.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the app.
|
2021-02-24 09:35:32 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function shouldAutoKnock(state: IReduxState): boolean {
|
2022-06-23 14:39:10 +00:00
|
|
|
const { iAmRecorder, iAmSipGateway, autoKnockLobby, prejoinConfig } = state['features/base/config'];
|
|
|
|
const { userSelectedSkipPrejoin } = state['features/base/settings'];
|
|
|
|
const isPrejoinEnabled = prejoinConfig?.enabled;
|
2021-02-24 09:35:32 +00:00
|
|
|
|
2022-09-23 07:48:20 +00:00
|
|
|
return Boolean(((isPrejoinEnabled && !userSelectedSkipPrejoin)
|
2022-06-23 14:39:10 +00:00
|
|
|
|| autoKnockLobby || (iAmRecorder && iAmSipGateway))
|
2022-09-23 07:48:20 +00:00
|
|
|
&& !state['features/lobby'].knocking);
|
2021-02-24 09:35:32 +00:00
|
|
|
}
|