Преглед изворни кода

[RN] Fix TypeError that getDefaultButtons is not a function

master
Lyubo Marinov пре 7 година
родитељ
комит
c2ca345dec

+ 1
- 0
react/features/toolbox/defaultToolbarButtons.native.js Прегледај датотеку

1
+export default undefined;

+ 26
- 21
react/features/toolbox/defaultToolbarButtons.web.js Прегледај датотеку

1
-/* @flow */
1
+// @flow
2
 
2
 
3
 import React from 'react';
3
 import React from 'react';
4
-import _ from 'lodash';
5
 
4
 
6
 import { ParticipantCounter } from '../contact-list';
5
 import { ParticipantCounter } from '../contact-list';
7
 import { openDeviceSelectionDialog } from '../device-selection';
6
 import { openDeviceSelectionDialog } from '../device-selection';
8
-
9
-import {
10
-    InfoDialogButton,
11
-    openInviteDialog
12
-} from '../invite';
13
-
14
-import { VideoQualityButton } from '../video-quality';
15
-
7
+import { InfoDialogButton, openInviteDialog } from '../invite';
16
 import UIEvents from '../../../service/UI/UIEvents';
8
 import UIEvents from '../../../service/UI/UIEvents';
9
+import { VideoQualityButton } from '../video-quality';
17
 
10
 
18
 import ProfileButton from './components/ProfileButton';
11
 import ProfileButton from './components/ProfileButton';
19
 
12
 
21
 declare var interfaceConfig: Object;
14
 declare var interfaceConfig: Object;
22
 declare var JitsiMeetJS: Object;
15
 declare var JitsiMeetJS: Object;
23
 
16
 
24
-let buttons: Object = {};
17
+/**
18
+ * The cache of {@link getDefaultButtons()}.
19
+ */
20
+let defaultButtons: Object;
25
 
21
 
26
 /**
22
 /**
27
  * Returns a map of all button descriptors and according properties.
23
  * Returns a map of all button descriptors and according properties.
28
  *
24
  *
29
- * @returns {*} - The maps of default button descriptors.
25
+ * @returns {Object} - The maps of default button descriptors.
30
  */
26
  */
31
-function getDefaultButtons() {
32
-    if (!_.isEmpty(buttons)) {
33
-        return buttons;
27
+export default function getDefaultButtons() {
28
+    if (defaultButtons) {
29
+        return defaultButtons;
34
     }
30
     }
35
 
31
 
36
-    buttons = {
32
+    defaultButtons = {
37
         /**
33
         /**
38
          * The descriptor of the camera toolbar button.
34
          * The descriptor of the camera toolbar button.
39
          */
35
          */
400
         }
396
         }
401
     };
397
     };
402
 
398
 
403
-    Object.keys(buttons).forEach(name => {
404
-        const button = buttons[name];
399
+    Object.keys(defaultButtons).forEach(name => {
400
+        const button = defaultButtons[name];
405
 
401
 
406
         if (!button.isDisplayed) {
402
         if (!button.isDisplayed) {
407
-            button.isDisplayed = () => !interfaceConfig.filmStripOnly;
403
+            button.isDisplayed = _isDisplayed;
408
         }
404
         }
409
     });
405
     });
410
 
406
 
411
-    return buttons;
407
+    return defaultButtons;
412
 }
408
 }
413
 
409
 
414
-export default getDefaultButtons;
410
+/**
411
+ * The default implementation of the {@code isDisplayed} method of the toolbar
412
+ * button definition returned by {@link getDefaultButtons()}.
413
+ *
414
+ * @returns {boolean} If the user intarface is full i.e. not filmstrip-only,
415
+ * then {@code true}; otherwise, {@code false}.
416
+ */
417
+function _isDisplayed() {
418
+    return !interfaceConfig.filmStripOnly;
419
+}

+ 11
- 11
react/features/toolbox/reducer.js Прегледај датотеку

1
-/* @flow */
1
+// @flow
2
 
2
 
3
 import { ReducerRegistry } from '../base/redux';
3
 import { ReducerRegistry } from '../base/redux';
4
 
4
 
155
             };
155
             };
156
 
156
 
157
         case SET_TOOLBAR_BUTTON:
157
         case SET_TOOLBAR_BUTTON:
158
-            return _setButton(state, action);
158
+            return _setToolbarButton(state, action);
159
 
159
 
160
         case SET_TOOLBAR_HOVERED:
160
         case SET_TOOLBAR_HOVERED:
161
             return {
161
             return {
199
     });
199
     });
200
 
200
 
201
 /**
201
 /**
202
- * Sets new value of the button.
202
+ * Reduces the redux action {@code SET_TOOLBAR_BUTTON} in the feature toolbox.
203
  *
203
  *
204
- * @param {Object} state - Redux state.
205
- * @param {Object} action - Dispatched action.
204
+ * @param {Object} state - The redux state.
205
+ * @param {Object} action - The redux action of type {@code SET_TOOLBAR_BUTTON}.
206
  * @param {Object} action.button - Object describing toolbar button.
206
  * @param {Object} action.button - Object describing toolbar button.
207
  * @param {Object} action.buttonName - The name of the button.
207
  * @param {Object} action.buttonName - The name of the button.
208
  * @private
208
  * @private
209
  * @returns {Object}
209
  * @returns {Object}
210
  */
210
  */
211
-function _setButton(state, { button, buttonName }): Object {
212
-    const buttons = getDefaultButtons();
213
-    const buttonDefinition = buttons ? buttons[buttonName] : null;
211
+function _setToolbarButton(state, { button, buttonName }): Object {
212
+    // XXX getDefaultButtons, defaultToolbarButtons, SET_TOOLBAR_BUTTON are
213
+    // abstractions fully implemented on Web only.
214
+    const buttons = getDefaultButtons && getDefaultButtons();
215
+    const buttonDefinition = buttons && buttons[buttonName];
214
 
216
 
215
     // We don't need to update if the button shouldn't be displayed
217
     // We don't need to update if the button shouldn't be displayed
216
     if (!buttonDefinition || !buttonDefinition.isDisplayed()) {
218
     if (!buttonDefinition || !buttonDefinition.isDisplayed()) {
217
-        return {
218
-            ...state
219
-        };
219
+        return state;
220
     }
220
     }
221
 
221
 
222
     const { primaryToolbarButtons, secondaryToolbarButtons } = state;
222
     const { primaryToolbarButtons, secondaryToolbarButtons } = state;

Loading…
Откажи
Сачувај