Переглянути джерело

rn,toolbox: simplify logic for showing Toolbox on mobile

master
Saúl Ibarra Corretgé 6 роки тому
джерело
коміт
64897b9c91

+ 2
- 48
react/features/conference/components/native/Conference.js Переглянути файл

6
 
6
 
7
 import { appNavigate } from '../../../app';
7
 import { appNavigate } from '../../../app';
8
 import { PIP_ENABLED, getFeatureFlag } from '../../../base/flags';
8
 import { PIP_ENABLED, getFeatureFlag } from '../../../base/flags';
9
-import { getParticipantCount } from '../../../base/participants';
10
 import { Container, LoadingIndicator, TintedView } from '../../../base/react';
9
 import { Container, LoadingIndicator, TintedView } from '../../../base/react';
11
 import { connect } from '../../../base/redux';
10
 import { connect } from '../../../base/redux';
12
 import {
11
 import {
27
 import { BackButtonRegistry } from '../../../mobile/back-button';
26
 import { BackButtonRegistry } from '../../../mobile/back-button';
28
 import { AddPeopleDialog, CalleeInfoContainer } from '../../../invite';
27
 import { AddPeopleDialog, CalleeInfoContainer } from '../../../invite';
29
 import { Captions } from '../../../subtitles';
28
 import { Captions } from '../../../subtitles';
30
-import { setToolboxVisible, Toolbox } from '../../../toolbox';
29
+import { isToolboxVisible, setToolboxVisible, Toolbox } from '../../../toolbox';
31
 
30
 
32
 import {
31
 import {
33
     AbstractConference,
32
     AbstractConference,
73
      */
72
      */
74
     _largeVideoParticipantId: string,
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
      * Whether Picture-in-Picture is enabled.
76
      * Whether Picture-in-Picture is enabled.
85
      *
77
      *
147
      */
139
      */
148
     componentDidMount() {
140
     componentDidMount() {
149
         BackButtonRegistry.addListener(this._onHardwareBackPress);
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
         leaving
381
         leaving
419
     } = state['features/base/conference'];
382
     } = state['features/base/conference'];
420
     const { reducedUI } = state['features/base/responsive-ui'];
383
     const { reducedUI } = state['features/base/responsive-ui'];
421
-    const { visible } = state['features/toolbox'];
422
 
384
 
423
     // XXX There is a window of time between the successful establishment of the
385
     // XXX There is a window of time between the successful establishment of the
424
     // XMPP connection and the subsequent commencement of joining the MUC during
386
     // XMPP connection and the subsequent commencement of joining the MUC during
464
          */
426
          */
465
         _largeVideoParticipantId: state['features/large-video'].participantId,
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
          * Whether Picture-in-Picture is enabled.
430
          * Whether Picture-in-Picture is enabled.
477
          *
431
          *
495
          * @private
449
          * @private
496
          * @type {boolean}
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
  * @returns {boolean}
10
  * @returns {boolean}
11
  */
11
  */
12
 export function isToolboxVisible(stateful: Object | Function) {
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
 }

Завантаження…
Відмінити
Зберегти