From d82bb0a89b893672841d32f977ee2db9015e48f1 Mon Sep 17 00:00:00 2001 From: Vlad Piersec Date: Fri, 14 Aug 2020 10:45:15 +0300 Subject: [PATCH] fix(prejoin): Fix join without audio --- react/features/base/config/actionTypes.js | 4 ++-- react/features/base/config/actions.js | 16 +++++++++++++++- react/features/base/config/middleware.js | 8 +++----- react/features/base/config/reducer.js | 4 ++-- react/features/prejoin/actions.js | 11 ++++++++--- react/features/prejoin/middleware.js | 4 ++++ 6 files changed, 34 insertions(+), 13 deletions(-) diff --git a/react/features/base/config/actionTypes.js b/react/features/base/config/actionTypes.js index d768f55fe..aaf15fc57 100644 --- a/react/features/base/config/actionTypes.js +++ b/react/features/base/config/actionTypes.js @@ -43,8 +43,8 @@ export const SET_CONFIG = 'SET_CONFIG'; * and the passed object. * * { - * type: _UPDATE_CONFIG, + * type: UPDATE_CONFIG, * config: Object * } */ -export const _UPDATE_CONFIG = '_UPDATE_CONFIG'; +export const UPDATE_CONFIG = 'UPDATE_CONFIG'; diff --git a/react/features/base/config/actions.js b/react/features/base/config/actions.js index d890ecbed..55b03ddb7 100644 --- a/react/features/base/config/actions.js +++ b/react/features/base/config/actions.js @@ -6,10 +6,24 @@ import type { Dispatch } from 'redux'; import { addKnownDomains } from '../known-domains'; import { parseURIString } from '../util'; -import { CONFIG_WILL_LOAD, LOAD_CONFIG_ERROR, SET_CONFIG } from './actionTypes'; +import { CONFIG_WILL_LOAD, LOAD_CONFIG_ERROR, SET_CONFIG, UPDATE_CONFIG } from './actionTypes'; import { _CONFIG_STORE_PREFIX } from './constants'; import { setConfigFromURLParams } from './functions'; + +/** + * Updates the config with new options. + * + * @param {Object} config - The new options (to add). + * @returns {Function} + */ +export function updateConfig(config: Object) { + return { + type: UPDATE_CONFIG, + config + }; +} + /** * Signals that the configuration (commonly known in Jitsi Meet as config.js) * for a specific locationURL will be loaded now. diff --git a/react/features/base/config/middleware.js b/react/features/base/config/middleware.js index 2a86a8240..96357dfaa 100644 --- a/react/features/base/config/middleware.js +++ b/react/features/base/config/middleware.js @@ -8,7 +8,8 @@ import { addKnownDomains } from '../known-domains'; import { MiddlewareRegistry } from '../redux'; import { parseURIString } from '../util'; -import { _UPDATE_CONFIG, SET_CONFIG } from './actionTypes'; +import { SET_CONFIG } from './actionTypes'; +import { updateConfig } from './actions'; import { _CONFIG_STORE_PREFIX } from './constants'; /** @@ -114,10 +115,7 @@ function _setConfig({ dispatch, getState }, next, action) { config.resolution = resolutionFlag; } - dispatch({ - type: _UPDATE_CONFIG, - config - }); + dispatch(updateConfig(config)); // FIXME On Web we rely on the global 'config' variable which gets altered // multiple times, before it makes it to the reducer. At some point it may diff --git a/react/features/base/config/reducer.js b/react/features/base/config/reducer.js index 43bd8f083..4a66c59d5 100644 --- a/react/features/base/config/reducer.js +++ b/react/features/base/config/reducer.js @@ -4,7 +4,7 @@ import _ from 'lodash'; import { equals, ReducerRegistry, set } from '../redux'; -import { _UPDATE_CONFIG, CONFIG_WILL_LOAD, LOAD_CONFIG_ERROR, SET_CONFIG } from './actionTypes'; +import { UPDATE_CONFIG, CONFIG_WILL_LOAD, LOAD_CONFIG_ERROR, SET_CONFIG } from './actionTypes'; import { _cleanupConfig } from './functions'; /** @@ -50,7 +50,7 @@ const INITIAL_RN_STATE = { ReducerRegistry.register('features/base/config', (state = _getInitialState(), action) => { switch (action.type) { - case _UPDATE_CONFIG: + case UPDATE_CONFIG: return _updateConfig(state, action); case CONFIG_WILL_LOAD: diff --git a/react/features/prejoin/actions.js b/react/features/prejoin/actions.js index a43075905..7255f8025 100644 --- a/react/features/prejoin/actions.js +++ b/react/features/prejoin/actions.js @@ -201,11 +201,13 @@ export function initPrejoin(tracks: Object[], errors: Object) { /** * Action used to start the conference. * + * @param {Object} options - The config options that override the default ones (if any). * @returns {Function} */ -export function joinConference() { +export function joinConference(options?: Object) { return { - type: PREJOIN_START_CONFERENCE + type: PREJOIN_START_CONFERENCE, + options }; } @@ -222,7 +224,10 @@ export function joinConferenceWithoutAudio() { if (audioTrack) { await dispatch(replaceLocalTrack(audioTrack, null)); } - dispatch(joinConference()); + + dispatch(joinConference({ + startSilent: true + })); }; } diff --git a/react/features/prejoin/middleware.js b/react/features/prejoin/middleware.js index 611bea577..c590d1b88 100644 --- a/react/features/prejoin/middleware.js +++ b/react/features/prejoin/middleware.js @@ -1,5 +1,6 @@ // @flow +import { updateConfig } from '../base/config'; import { SET_AUDIO_MUTED, SET_VIDEO_MUTED } from '../base/media'; import { MiddlewareRegistry } from '../base/redux'; import { updateSettings } from '../base/settings'; @@ -24,6 +25,9 @@ MiddlewareRegistry.register(store => next => async action => { const state = getState(); const { userSelectedSkipPrejoin } = state['features/prejoin']; const localVideoTrack = getLocalVideoTrack(state['features/base/tracks']); + const { options } = action; + + options && store.dispatch(updateConfig(options)); userSelectedSkipPrejoin && dispatch(updateSettings({ userSelectedSkipPrejoin