[RN] Fix TypeError that getDefaultButtons is not a function

This commit is contained in:
Lyubo Marinov 2017-10-03 17:26:13 -05:00
parent 1834fc63d2
commit c2ca345dec
3 changed files with 38 additions and 32 deletions

View File

@ -0,0 +1 @@
export default undefined;

View File

@ -1,19 +1,12 @@
/* @flow */
// @flow
import React from 'react';
import _ from 'lodash';
import { ParticipantCounter } from '../contact-list';
import { openDeviceSelectionDialog } from '../device-selection';
import {
InfoDialogButton,
openInviteDialog
} from '../invite';
import { VideoQualityButton } from '../video-quality';
import { InfoDialogButton, openInviteDialog } from '../invite';
import UIEvents from '../../../service/UI/UIEvents';
import { VideoQualityButton } from '../video-quality';
import ProfileButton from './components/ProfileButton';
@ -21,19 +14,22 @@ declare var APP: Object;
declare var interfaceConfig: Object;
declare var JitsiMeetJS: Object;
let buttons: Object = {};
/**
* The cache of {@link getDefaultButtons()}.
*/
let defaultButtons: Object;
/**
* Returns a map of all button descriptors and according properties.
*
* @returns {*} - The maps of default button descriptors.
* @returns {Object} - The maps of default button descriptors.
*/
function getDefaultButtons() {
if (!_.isEmpty(buttons)) {
return buttons;
export default function getDefaultButtons() {
if (defaultButtons) {
return defaultButtons;
}
buttons = {
defaultButtons = {
/**
* The descriptor of the camera toolbar button.
*/
@ -400,15 +396,24 @@ function getDefaultButtons() {
}
};
Object.keys(buttons).forEach(name => {
const button = buttons[name];
Object.keys(defaultButtons).forEach(name => {
const button = defaultButtons[name];
if (!button.isDisplayed) {
button.isDisplayed = () => !interfaceConfig.filmStripOnly;
button.isDisplayed = _isDisplayed;
}
});
return buttons;
return defaultButtons;
}
export default getDefaultButtons;
/**
* The default implementation of the {@code isDisplayed} method of the toolbar
* button definition returned by {@link getDefaultButtons()}.
*
* @returns {boolean} If the user intarface is full i.e. not filmstrip-only,
* then {@code true}; otherwise, {@code false}.
*/
function _isDisplayed() {
return !interfaceConfig.filmStripOnly;
}

View File

@ -1,4 +1,4 @@
/* @flow */
// @flow
import { ReducerRegistry } from '../base/redux';
@ -155,7 +155,7 @@ ReducerRegistry.register(
};
case SET_TOOLBAR_BUTTON:
return _setButton(state, action);
return _setToolbarButton(state, action);
case SET_TOOLBAR_HOVERED:
return {
@ -199,24 +199,24 @@ ReducerRegistry.register(
});
/**
* Sets new value of the button.
* Reduces the redux action {@code SET_TOOLBAR_BUTTON} in the feature toolbox.
*
* @param {Object} state - Redux state.
* @param {Object} action - Dispatched action.
* @param {Object} state - The redux state.
* @param {Object} action - The redux action of type {@code SET_TOOLBAR_BUTTON}.
* @param {Object} action.button - Object describing toolbar button.
* @param {Object} action.buttonName - The name of the button.
* @private
* @returns {Object}
*/
function _setButton(state, { button, buttonName }): Object {
const buttons = getDefaultButtons();
const buttonDefinition = buttons ? buttons[buttonName] : null;
function _setToolbarButton(state, { button, buttonName }): Object {
// XXX getDefaultButtons, defaultToolbarButtons, SET_TOOLBAR_BUTTON are
// abstractions fully implemented on Web only.
const buttons = getDefaultButtons && getDefaultButtons();
const buttonDefinition = buttons && buttons[buttonName];
// We don't need to update if the button shouldn't be displayed
if (!buttonDefinition || !buttonDefinition.isDisplayed()) {
return {
...state
};
return state;
}
const { primaryToolbarButtons, secondaryToolbarButtons } = state;