2020-04-16 10:47:10 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-05-14 12:30:24 +00:00
|
|
|
import { getRoomName } from '../base/conference';
|
|
|
|
import { getDialOutStatusUrl, getDialOutUrl } from '../base/config/functions';
|
2020-06-19 07:03:26 +00:00
|
|
|
import { isAudioMuted, isVideoMutedByUser } from '../base/media';
|
2020-04-16 10:47:10 +00:00
|
|
|
|
2021-08-20 08:53:11 +00:00
|
|
|
import { PREJOIN_SCREEN_STATES } from './constants';
|
|
|
|
|
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
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2020-05-19 07:52:57 +00:00
|
|
|
export function isJoinByPhoneButtonVisible(state: Object): 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.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isDeviceStatusVisible(state: Object): 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.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isDisplayNameRequired(state: Object): boolean {
|
|
|
|
return state['features/prejoin'].isDisplayNameRequired
|
|
|
|
|| state['features/base/config'].requireDisplayName;
|
|
|
|
}
|
|
|
|
|
2020-07-15 08:06:14 +00:00
|
|
|
/**
|
|
|
|
* Selector for determining if the user has chosen to skip prejoin page.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isPrejoinSkipped(state: Object) {
|
|
|
|
return state['features/prejoin'].userSelectedSkipPrejoin;
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
|
|
|
* Returns the text for the prejoin status bar.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export function getDeviceStatusText(state: Object): 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'.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export function getDeviceStatusType(state: Object): 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.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export function getDialOutConferenceUrl(state: Object): string {
|
|
|
|
return `${getRoomName(state)}@${state['features/base/config'].hosts.muc}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selector for getting the dial out country.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function getDialOutCountry(state: Object): Object {
|
|
|
|
return state['features/prejoin'].dialOutCountry;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selector for getting the dial out number (without prefix).
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export function getDialOutNumber(state: Object): string {
|
|
|
|
return state['features/prejoin'].dialOutNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selector for getting the dial out status while calling.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export function getDialOutStatus(state: Object): string {
|
|
|
|
return state['features/prejoin'].dialOutStatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the full dial out number (containing country code and +).
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export function getFullDialOutNumber(state: Object): string {
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export function getRawError(state: Object): 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
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isJoinByPhoneDialogVisible(state: Object): 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.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isPrejoinPageEnabled(state: Object): boolean {
|
2020-05-20 08:25:31 +00:00
|
|
|
return navigator.product !== 'ReactNative'
|
|
|
|
&& state['features/base/config'].prejoinPageEnabled
|
2021-02-04 17:33:18 +00:00
|
|
|
&& !state['features/base/settings'].userSelectedSkipPrejoin
|
|
|
|
&& !(state['features/base/config'].enableForcedReload && state['features/prejoin'].skipPrejoinOnReload);
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the prejoin page is visible & active.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isPrejoinPageVisible(state: Object): boolean {
|
2021-08-20 08:53:11 +00:00
|
|
|
return isPrejoinPageEnabled(state) && state['features/prejoin']?.showPrejoin === PREJOIN_SCREEN_STATES.VISIBLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the prejoin page is loading.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isPrejoinPageLoading(state: Object): boolean {
|
|
|
|
return isPrejoinPageEnabled(state) && state['features/prejoin']?.showPrejoin === PREJOIN_SCREEN_STATES.LOADING;
|
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.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function shouldAutoKnock(state: Object): boolean {
|
|
|
|
const { iAmRecorder, iAmSipGateway } = state['features/base/config'];
|
|
|
|
|
|
|
|
return (isPrejoinPageEnabled(state) || (iAmRecorder && iAmSipGateway))
|
|
|
|
&& !state['features/lobby'].knocking;
|
|
|
|
}
|