fix(prejoin) Consider user selection for prejoin only on mount

This commit is contained in:
Horatiu Muresan 2021-12-20 11:34:40 +02:00 committed by GitHub
parent d44660527b
commit d22d95e8a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 62 deletions

View File

@ -135,7 +135,6 @@ import { mediaPermissionPromptVisibilityChanged, toggleSlowGUMOverlay } from './
import { suspendDetected } from './react/features/power-monitor'; import { suspendDetected } from './react/features/power-monitor';
import { import {
initPrejoin, initPrejoin,
isPrejoinPageEnabled,
isPrejoinPageVisible, isPrejoinPageVisible,
makePrecallTest, makePrecallTest,
setJoiningInProgress, setJoiningInProgress,
@ -797,7 +796,7 @@ export default {
logger.warn('initial device list initialization failed', error); logger.warn('initial device list initialization failed', error);
} }
if (isPrejoinPageEnabled(APP.store.getState())) { if (isPrejoinPageVisible(APP.store.getState())) {
_connectionPromise = connect(roomName).then(c => { _connectionPromise = connect(roomName).then(c => {
// we want to initialize it early, in case of errors to be able // we want to initialize it early, in case of errors to be able
// to gather logs // to gather logs

View File

@ -2,6 +2,7 @@
import _ from 'lodash'; import _ from 'lodash';
import { PREJOIN_INITIALIZED } from '../../prejoin/actionTypes'; import { PREJOIN_INITIALIZED } from '../../prejoin/actionTypes';
import { setPrejoinPageVisibility } from '../../prejoin/actions';
import { APP_WILL_MOUNT } from '../app'; import { APP_WILL_MOUNT } from '../app';
import { setAudioOnly } from '../audio-only'; import { setAudioOnly } from '../audio-only';
import { SET_LOCATION_URL } from '../connection/actionTypes'; // minimize imports to avoid circular imports import { SET_LOCATION_URL } from '../connection/actionTypes'; // minimize imports to avoid circular imports
@ -29,6 +30,7 @@ MiddlewareRegistry.register(store => next => action => {
switch (action.type) { switch (action.type) {
case APP_WILL_MOUNT: case APP_WILL_MOUNT:
_initializeCallIntegration(store); _initializeCallIntegration(store);
_initializeShowPrejoin(store);
break; break;
case PREJOIN_INITIALIZED: { case PREJOIN_INITIALIZED: {
_maybeUpdateDisplayName(store); _maybeUpdateDisplayName(store);
@ -48,6 +50,21 @@ MiddlewareRegistry.register(store => next => action => {
return result; return result;
}); });
/**
* Overwrites the showPrejoin flag based on cached used selection for showing prejoin screen.
*
* @param {Store} store - The redux store.
* @private
* @returns {void}
*/
function _initializeShowPrejoin({ dispatch, getState }) {
const { userSelectedSkipPrejoin } = getState()['features/base/settings'];
if (userSelectedSkipPrejoin) {
dispatch(setPrejoinPageVisibility(false));
}
}
/** /**
* Initializes the audio device handler based on the `disableCallIntegration` setting. * Initializes the audio device handler based on the `disableCallIntegration` setting.
* *

View File

@ -14,11 +14,6 @@ export const PREJOIN_INITIALIZED = 'PREJOIN_INITIALIZED';
*/ */
export const SET_DEVICE_STATUS = 'SET_DEVICE_STATUS'; export const SET_DEVICE_STATUS = 'SET_DEVICE_STATUS';
/**
* Action type to mark the fact that the 'skip prejoin' option was modified this session.
*/
export const SET_SKIP_PREJOIN_CHANGING = 'SET_SKIP_PREJOIN_CHANGING';
/** /**
* Action type to set the visibility of the prejoin page when client is forcefully reloaded. * Action type to set the visibility of the prejoin page when client is forcefully reloaded.
*/ */

View File

@ -27,7 +27,6 @@ import {
SET_DIALOUT_NUMBER, SET_DIALOUT_NUMBER,
SET_DIALOUT_STATUS, SET_DIALOUT_STATUS,
SET_PREJOIN_DISPLAY_NAME_REQUIRED, SET_PREJOIN_DISPLAY_NAME_REQUIRED,
SET_SKIP_PREJOIN_CHANGING,
SET_SKIP_PREJOIN_RELOAD, SET_SKIP_PREJOIN_RELOAD,
SET_JOIN_BY_PHONE_DIALOG_VISIBLITY, SET_JOIN_BY_PHONE_DIALOG_VISIBLITY,
SET_PRECALL_TEST_RESULTS, SET_PRECALL_TEST_RESULTS,
@ -477,20 +476,6 @@ export function setDialOutNumber(value: string) {
}; };
} }
/**
* Sets a flag which signals that the option to skip the prejoin
* page on join has been modified during this session.
*
* @param {boolean} value - The visibility value.
* @returns {Object}
*/
export function setSkipPrejoinIsChanging(value: boolean) {
return {
type: SET_SKIP_PREJOIN_CHANGING,
value
};
}
/** /**
* Sets the visibility of the prejoin page when a client reload * Sets the visibility of the prejoin page when a client reload
* is triggered as a result of call migration initiated by Jicofo. * is triggered as a result of call migration initiated by Jicofo.

View File

@ -136,29 +136,13 @@ export function isJoinByPhoneDialogVisible(state: Object): boolean {
* @param {Object} state - The state of the app. * @param {Object} state - The state of the app.
* @returns {boolean} * @returns {boolean}
*/ */
export function isPrejoinPageEnabled(state: Object): boolean { export function isPrejoinPageVisible(state: Object): boolean {
return navigator.product !== 'ReactNative' return navigator.product !== 'ReactNative'
&& state['features/base/config'].prejoinConfig?.enabled && state['features/base/config'].prejoinConfig?.enabled
&& !state['features/base/settings'].userSelectedSkipPrejoin && state['features/prejoin']?.showPrejoin
&& !(state['features/base/config'].enableForcedReload && state['features/prejoin'].skipPrejoinOnReload); && !(state['features/base/config'].enableForcedReload && state['features/prejoin'].skipPrejoinOnReload);
} }
/**
* 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 {
// If the user has changed the setting for prejoin visibility on start
// let the visibility be controlled only by the 'showPrejoin' flag.
if (state['features/prejoin'].skipPrejoinChanging) {
return state['features/prejoin']?.showPrejoin;
}
return isPrejoinPageEnabled(state) && state['features/prejoin']?.showPrejoin;
}
/** /**
* Returns true if we should auto-knock in case lobby is enabled for the room. * Returns true if we should auto-knock in case lobby is enabled for the room.
* *
@ -168,6 +152,6 @@ export function isPrejoinPageVisible(state: Object): boolean {
export function shouldAutoKnock(state: Object): boolean { export function shouldAutoKnock(state: Object): boolean {
const { iAmRecorder, iAmSipGateway, autoKnockLobby } = state['features/base/config']; const { iAmRecorder, iAmSipGateway, autoKnockLobby } = state['features/base/config'];
return (isPrejoinPageEnabled(state) || autoKnockLobby || (iAmRecorder && iAmSipGateway)) return (isPrejoinPageVisible(state) || autoKnockLobby || (iAmRecorder && iAmSipGateway))
&& !state['features/lobby'].knocking; && !state['features/lobby'].knocking;
} }

View File

@ -11,7 +11,6 @@ import {
SET_PREJOIN_DEVICE_ERRORS, SET_PREJOIN_DEVICE_ERRORS,
SET_PREJOIN_DISPLAY_NAME_REQUIRED, SET_PREJOIN_DISPLAY_NAME_REQUIRED,
SET_PREJOIN_PAGE_VISIBILITY, SET_PREJOIN_PAGE_VISIBILITY,
SET_SKIP_PREJOIN_CHANGING,
SET_SKIP_PREJOIN_RELOAD SET_SKIP_PREJOIN_RELOAD
} from './actionTypes'; } from './actionTypes';
@ -30,7 +29,6 @@ const DEFAULT_STATE = {
name: '', name: '',
rawError: '', rawError: '',
showPrejoin: true, showPrejoin: true,
skipPrejoinChanging: false,
skipPrejoinOnReload: false, skipPrejoinOnReload: false,
showJoinByPhoneDialog: false showJoinByPhoneDialog: false
}; };
@ -59,13 +57,6 @@ ReducerRegistry.register(
...state, ...state,
joiningInProgress: action.value joiningInProgress: action.value
}; };
case SET_SKIP_PREJOIN_CHANGING: {
return {
...state,
skipPrejoinChanging: action.value
};
}
case SET_SKIP_PREJOIN_RELOAD: { case SET_SKIP_PREJOIN_RELOAD: {
return { return {
...state, ...state,

View File

@ -10,7 +10,6 @@ import {
import { openDialog } from '../base/dialog'; import { openDialog } from '../base/dialog';
import { i18next } from '../base/i18n'; import { i18next } from '../base/i18n';
import { updateSettings } from '../base/settings'; import { updateSettings } from '../base/settings';
import { setPrejoinPageVisibility, setSkipPrejoinIsChanging } from '../prejoin/actions';
import { setScreenshareFramerate } from '../screen-share/actions'; import { setScreenshareFramerate } from '../screen-share/actions';
import { import {
@ -88,17 +87,9 @@ export function submitMoreTab(newState: Object): Function {
const showPrejoinPage = newState.showPrejoinPage; const showPrejoinPage = newState.showPrejoinPage;
if (showPrejoinPage !== currentState.showPrejoinPage) { if (showPrejoinPage !== currentState.showPrejoinPage) {
// The 'showPrejoin' flag starts as 'true' on every new session. dispatch(updateSettings({
// This prevents displaying the prejoin page when the user re-enables it. userSelectedSkipPrejoin: !showPrejoinPage
if (showPrejoinPage && getState()['features/prejoin']?.showPrejoin) { }));
dispatch(setPrejoinPageVisibility(false));
}
batch(() => {
dispatch(setSkipPrejoinIsChanging(true));
dispatch(updateSettings({
userSelectedSkipPrejoin: !showPrejoinPage
}));
});
} }
const enabledNotifications = newState.enabledNotifications; const enabledNotifications = newState.enabledNotifications;