Fix TypeError: Cannot read property 'isGuest' of undefined

This commit is contained in:
Lyubo Marinov 2017-05-17 16:44:28 -05:00
parent db59b45076
commit 3c31a60b32
5 changed files with 34 additions and 41 deletions

View File

@ -58,6 +58,13 @@ function _setConfig(state, action) {
// The config of INITIAL_STATE is meant to override the config
// downloaded from the Jitsi Meet deployment because the former contains
// values that are mandatory.
//
// FIXME At the time of this writing the hard-coded overriding values
// are specific to mobile/React Native but the source code here is
// executed on Web/React as well. The latter is not a practical problem
// right now because the rest of the Web/React source code does not read
// the overridden properties/values, it still relies on the global
// variable config.
...INITIAL_STATE
};
}

View File

@ -21,15 +21,9 @@ export function disposeLib() {
return (dispatch: Dispatch<*>) => {
dispatch({ type: LIB_WILL_DISPOSE });
// XXX We're wrapping it with Promise because:
// a) to be better aligned with initLib() method which is async;
// b) as currently there is no implementation for it in lib-jitsi-meet
// and there is a big chance it will be async.
// TODO Currently, lib-jitsi-meet doesn't have the functionality to
// dispose itself.
return (
Promise.resolve()
.then(() => dispatch({ type: LIB_DID_DISPOSE })));
dispatch({ type: LIB_DID_DISPOSE });
};
}

View File

@ -99,22 +99,23 @@ function _setConfig({ dispatch, getState }, next, action) {
// disposed of first.
// TODO Currently, disposeLib actually does not dispose of lib-jitsi-meet
// because lib-jitsi-meet does not implement such functionality.
const disposeLibPromise
= initialized ? dispatch(disposeLib()) : Promise.resolve();
if (initialized) {
dispatch(disposeLib());
}
disposeLibPromise.then(() => {
// Let the new config into the Redux store (because initLib will read it
// from there).
next(action);
// Let the new config into the Redux store (because initLib will read it
// from there).
const result = next(action);
// FIXME Obviously, the following is bad design. However, I'm currently
// introducing the features base/config and base/logging and I'm trying
// to minimize the scope of the changes while I'm attempting to preserve
// compatibility with the existing partially React-ified Web source code
// and what was already executing on React Native. Additionally, I do
// not care to load logging_config.js on React Native.
dispatch(setLoggingConfig(window.loggingConfig));
// FIXME Obviously, the following is bad design. However, I'm currently
// introducing the features base/config and base/logging and I'm trying to
// minimize the scope of the changes while I'm attempting to preserve
// compatibility with the existing partially React-ified Web source code and
// what was already executing on React Native. Additionally, I do not care
// to load logging_config.js on React Native.
dispatch(setLoggingConfig(window.loggingConfig));
dispatch(initLib());
});
dispatch(initLib());
return result;
}

View File

@ -1,6 +1,6 @@
/* @flow */
const userAgent = navigator.userAgent;
const { userAgent } = navigator;
let OS;
if (userAgent.match(/Android/i)) {

View File

@ -172,9 +172,8 @@ export function showDesktopSharingButton(): Function {
export function showDialPadButton(show: boolean): Function {
return (dispatch: Dispatch<*>) => {
const buttonName = 'dialpad';
const shouldShow = UIUtil.isButtonEnabled(buttonName) && show;
if (shouldShow) {
if (show && UIUtil.isButtonEnabled(buttonName)) {
dispatch(setToolbarButton(buttonName, {
hidden: false
}));
@ -205,11 +204,9 @@ export function showRecordingButton(): Function {
export function showSharedVideoButton(): Function {
return (dispatch: Dispatch<*>) => {
const buttonName = 'sharedvideo';
const shouldShow
= UIUtil.isButtonEnabled(buttonName)
&& !config.disableThirdPartyRequests;
if (shouldShow) {
if (UIUtil.isButtonEnabled(buttonName)
&& !config.disableThirdPartyRequests) {
dispatch(setToolbarButton(buttonName, {
hidden: false
}));
@ -218,28 +215,22 @@ export function showSharedVideoButton(): Function {
}
/**
* Shows SIP call button if it's required and appropriate
* flag is passed.
* Shows SIP call button if it's required and appropriate flag is passed.
*
* @param {boolean} show - Flag showing whether to show button or not.
* @returns {Function}
*/
export function showSIPCallButton(show: boolean): Function {
return (dispatch: Dispatch<*>) => {
return (dispatch: Dispatch<*>, getState: Function) => {
const buttonName = 'sip';
// hide the button if there is a config to check for user roles,
// based on the token and the the user is guest
const shouldShow
= APP.conference.sipGatewayEnabled()
if (show
&& APP.conference.sipGatewayEnabled()
&& UIUtil.isButtonEnabled(buttonName)
&& show
&& (!config.enableUserRolesBasedOnToken
|| !APP.tokenData.isGuest);
if (shouldShow) {
|| !getState()['features/jwt'].isGuest)) {
dispatch(setToolbarButton(buttonName, {
hidden: !shouldShow
hidden: false
}));
}
};