浏览代码

rn,toolbox: simplify logic for showing Toolbox on mobile

master
Saúl Ibarra Corretgé 6 年前
父节点
当前提交
64897b9c91
共有 2 个文件被更改,包括 6 次插入51 次删除
  1. 2
    48
      react/features/conference/components/native/Conference.js
  2. 4
    3
      react/features/toolbox/functions.native.js

+ 2
- 48
react/features/conference/components/native/Conference.js 查看文件

@@ -6,7 +6,6 @@ import LinearGradient from 'react-native-linear-gradient';
6 6
 
7 7
 import { appNavigate } from '../../../app';
8 8
 import { PIP_ENABLED, getFeatureFlag } from '../../../base/flags';
9
-import { getParticipantCount } from '../../../base/participants';
10 9
 import { Container, LoadingIndicator, TintedView } from '../../../base/react';
11 10
 import { connect } from '../../../base/redux';
12 11
 import {
@@ -27,7 +26,7 @@ import { LargeVideo } from '../../../large-video';
27 26
 import { BackButtonRegistry } from '../../../mobile/back-button';
28 27
 import { AddPeopleDialog, CalleeInfoContainer } from '../../../invite';
29 28
 import { Captions } from '../../../subtitles';
30
-import { setToolboxVisible, Toolbox } from '../../../toolbox';
29
+import { isToolboxVisible, setToolboxVisible, Toolbox } from '../../../toolbox';
31 30
 
32 31
 import {
33 32
     AbstractConference,
@@ -73,13 +72,6 @@ type Props = AbstractProps & {
73 72
      */
74 73
     _largeVideoParticipantId: string,
75 74
 
76
-    /**
77
-     * The number of participants in the conference.
78
-     *
79
-     * @private
80
-     */
81
-    _participantCount: number,
82
-
83 75
     /**
84 76
      * Whether Picture-in-Picture is enabled.
85 77
      *
@@ -147,35 +139,6 @@ class Conference extends AbstractConference<Props, *> {
147 139
      */
148 140
     componentDidMount() {
149 141
         BackButtonRegistry.addListener(this._onHardwareBackPress);
150
-
151
-        // Show the toolbox if we are the only participant; otherwise, the whole
152
-        // UI looks too unpopulated the LargeVideo visible.
153
-        this.props._participantCount === 1 && this._setToolboxVisible(true);
154
-    }
155
-
156
-    /**
157
-     * Implements React's {@link Component#componentDidUpdate()}.
158
-     *
159
-     * @inheritdoc
160
-     */
161
-    componentDidUpdate(prevProps: Props) {
162
-        const {
163
-            _participantCount: oldParticipantCount
164
-        } = prevProps;
165
-        const {
166
-            _participantCount: newParticipantCount,
167
-            _toolboxVisible
168
-        } = this.props;
169
-
170
-        if (oldParticipantCount === 1
171
-                && newParticipantCount > 1
172
-                && _toolboxVisible) {
173
-            this._setToolboxVisible(false);
174
-        } else if (oldParticipantCount > 1
175
-                && newParticipantCount === 1
176
-                && !_toolboxVisible) {
177
-            this._setToolboxVisible(true);
178
-        }
179 142
     }
180 143
 
181 144
     /**
@@ -418,7 +381,6 @@ function _mapStateToProps(state) {
418 381
         leaving
419 382
     } = state['features/base/conference'];
420 383
     const { reducedUI } = state['features/base/responsive-ui'];
421
-    const { visible } = state['features/toolbox'];
422 384
 
423 385
     // XXX There is a window of time between the successful establishment of the
424 386
     // XMPP connection and the subsequent commencement of joining the MUC during
@@ -464,14 +426,6 @@ function _mapStateToProps(state) {
464 426
          */
465 427
         _largeVideoParticipantId: state['features/large-video'].participantId,
466 428
 
467
-        /**
468
-         * The number of participants in the conference.
469
-         *
470
-         * @private
471
-         * @type {number}
472
-         */
473
-        _participantCount: getParticipantCount(state),
474
-
475 429
         /**
476 430
          * Whether Picture-in-Picture is enabled.
477 431
          *
@@ -495,7 +449,7 @@ function _mapStateToProps(state) {
495 449
          * @private
496 450
          * @type {boolean}
497 451
          */
498
-        _toolboxVisible: visible
452
+        _toolboxVisible: isToolboxVisible(state)
499 453
     };
500 454
 }
501 455
 

+ 4
- 3
react/features/toolbox/functions.native.js 查看文件

@@ -10,8 +10,9 @@ import { toState } from '../base/redux';
10 10
  * @returns {boolean}
11 11
  */
12 12
 export function isToolboxVisible(stateful: Object | Function) {
13
-    const { alwaysVisible, enabled, visible }
14
-        = toState(stateful)['features/toolbox'];
13
+    const state = toState(stateful);
14
+    const { alwaysVisible, enabled, visible } = state['features/toolbox'];
15
+    const { length: participantCount } = state['features/base/participants'];
15 16
 
16
-    return enabled && (alwaysVisible || visible);
17
+    return enabled && (alwaysVisible || visible || participantCount === 1);
17 18
 }

正在加载...
取消
保存