Bladeren bron

fix(mobile-pagination): address PR review comments

master
Hristo Terezov 4 jaren geleden
bovenliggende
commit
b31ed40309

+ 1
- 1
react/features/filmstrip/components/native/Filmstrip.js Bestand weergeven

@@ -237,7 +237,7 @@ class Filmstrip extends PureComponent<Props> {
237 237
                     renderItem = { this._renderThumbnail }
238 238
                     showsHorizontalScrollIndicator = { false }
239 239
                     showsVerticalScrollIndicator = { false }
240
-                    style = { styles.scrollView }
240
+                    style = { styles.flatListStageView }
241 241
                     viewabilityConfig = { this._viewabilityConfig }
242 242
                     windowSize = { 2 } />
243 243
                 {

+ 51
- 37
react/features/filmstrip/components/native/Thumbnail.js Bestand weergeven

@@ -52,7 +52,7 @@ type Props = {
52 52
     _isFakeParticipant: boolean,
53 53
 
54 54
     /**
55
-     * Indicates whether the participant is fake.
55
+     * Indicates whether the participant is screen sharing.
56 56
      */
57 57
     _isScreenShare: boolean,
58 58
 
@@ -200,12 +200,11 @@ class Thumbnail extends PureComponent<Props> {
200 200
     }
201 201
 
202 202
     /**
203
-     * Implements React's {@link Component#render()}.
203
+     * Renders the indicators for the thumbnail.
204 204
      *
205
-     * @inheritdoc
206 205
      * @returns {ReactElement}
207 206
      */
208
-    render() {
207
+    _renderIndicators() {
209 208
         const {
210 209
             _audioMuted: audioMuted,
211 210
             _isScreenShare: isScreenShare,
@@ -213,10 +212,56 @@ class Thumbnail extends PureComponent<Props> {
213 212
             _renderDominantSpeakerIndicator: renderDominantSpeakerIndicator,
214 213
             _renderModeratorIndicator: renderModeratorIndicator,
215 214
             _participantId: participantId,
215
+            _videoMuted: videoMuted
216
+        } = this.props;
217
+        const indicators = [];
218
+
219
+        if (renderModeratorIndicator) {
220
+            indicators.push(<View style = { styles.moderatorIndicatorContainer }>
221
+                <ModeratorIndicator />
222
+            </View>);
223
+        }
224
+
225
+        if (!_isFakeParticipant) {
226
+            indicators.push(<View
227
+                style = { [
228
+                    styles.thumbnailTopIndicatorContainer,
229
+                    styles.thumbnailTopLeftIndicatorContainer
230
+                ] }>
231
+                <RaisedHandIndicator participantId = { participantId } />
232
+                { renderDominantSpeakerIndicator && <DominantSpeakerIndicator /> }
233
+            </View>);
234
+            indicators.push(<View
235
+                style = { [
236
+                    styles.thumbnailTopIndicatorContainer,
237
+                    styles.thumbnailTopRightIndicatorContainer
238
+                ] }>
239
+                <ConnectionIndicator participantId = { participantId } />
240
+            </View>);
241
+            indicators.push(<Container style = { styles.thumbnailIndicatorContainer }>
242
+                { audioMuted && <AudioMutedIndicator /> }
243
+                { videoMuted && <VideoMutedIndicator /> }
244
+                { isScreenShare && <ScreenShareIndicator /> }
245
+            </Container>);
246
+        }
247
+
248
+        return indicators;
249
+    }
250
+
251
+    /**
252
+     * Implements React's {@link Component#render()}.
253
+     *
254
+     * @inheritdoc
255
+     * @returns {ReactElement}
256
+     */
257
+    render() {
258
+        const {
259
+            _isScreenShare: isScreenShare,
260
+            _isFakeParticipant,
261
+            _participantId: participantId,
216 262
             _participantInLargeVideo: participantInLargeVideo,
217 263
             _pinned,
218 264
             _styles,
219
-            _videoMuted: videoMuted,
220 265
             disableTint,
221 266
             height,
222 267
             renderDisplayName,
@@ -255,39 +300,8 @@ class Thumbnail extends PureComponent<Props> {
255 300
                             <DisplayNameLabel participantId = { participantId } />
256 301
                         </Container>
257 302
                 }
258
-                { renderModeratorIndicator
259
-                    && <View style = { styles.moderatorIndicatorContainer }>
260
-                        <ModeratorIndicator />
261
-                    </View>
262
-                }
263
-                {
264
-                    !_isFakeParticipant
265
-                        && <View
266
-                            style = { [
267
-                                styles.thumbnailTopIndicatorContainer,
268
-                                styles.thumbnailTopLeftIndicatorContainer
269
-                            ] }>
270
-                            <RaisedHandIndicator participantId = { participantId } />
271
-                            { renderDominantSpeakerIndicator && <DominantSpeakerIndicator /> }
272
-                        </View>
273
-                }
274 303
                 {
275
-                    !_isFakeParticipant
276
-                        && <View
277
-                            style = { [
278
-                                styles.thumbnailTopIndicatorContainer,
279
-                                styles.thumbnailTopRightIndicatorContainer
280
-                            ] }>
281
-                            <ConnectionIndicator participantId = { participantId } />
282
-                        </View>
283
-                }
284
-                {
285
-                    !_isFakeParticipant
286
-                        && <Container style = { styles.thumbnailIndicatorContainer }>
287
-                            { audioMuted && <AudioMutedIndicator /> }
288
-                            { videoMuted && <VideoMutedIndicator /> }
289
-                            { isScreenShare && <ScreenShareIndicator /> }
290
-                        </Container>
304
+                    this._renderIndicators()
291 305
                 }
292 306
             </Container>
293 307
         );

+ 12
- 5
react/features/filmstrip/components/native/TileView.js Bestand weergeven

@@ -71,6 +71,12 @@ type Props = {
71 71
     onClick: Function
72 72
 };
73 73
 
74
+/**
75
+ * An empty array. The purpose of the constant is to use the same reference every time we need an empty array.
76
+ * This will prevent unnecessary re-renders.
77
+ */
78
+const EMPTY_ARRAY = [];
79
+
74 80
 /**
75 81
  * Implements a React {@link PureComponent} which displays thumbnails in a two
76 82
  * dimensional grid.
@@ -109,7 +115,7 @@ class TileView extends PureComponent<Props> {
109 115
             itemVisiblePercentThreshold: 30
110 116
         };
111 117
         this._flatListStyles = {
112
-            ...styles.flatList
118
+            ...styles.flatListTileView
113 119
         };
114 120
         this._contentContainerStyles = {
115 121
             ...styles.contentContainer
@@ -162,7 +168,7 @@ class TileView extends PureComponent<Props> {
162 168
 
163 169
         if (this._flatListStyles.minHeight !== _height || this._flatListStyles.minWidth !== _width) {
164 170
             this._flatListStyles = {
165
-                ...styles.flatList,
171
+                ...styles.flatListTileView,
166 172
                 minHeight: _height,
167 173
                 minWidth: _width
168 174
             };
@@ -207,11 +213,12 @@ class TileView extends PureComponent<Props> {
207 213
      */
208 214
     _getSortedParticipants() {
209 215
         const { _localParticipant, _remoteParticipants } = this.props;
210
-        const participants = [];
211 216
 
212
-        _localParticipant && participants.push(_localParticipant.id);
217
+        if (!_localParticipant) {
218
+            return EMPTY_ARRAY;
219
+        }
213 220
 
214
-        return [ ...participants, ..._remoteParticipants ];
221
+        return [ _localParticipant?.id, ..._remoteParticipants ];
215 222
     }
216 223
 
217 224
     _renderThumbnail: Object => Object;

+ 9
- 9
react/features/filmstrip/components/native/styles.js Bestand weergeven

@@ -71,9 +71,16 @@ export default {
71 71
     },
72 72
 
73 73
     /**
74
-     * The styles for the FlatList.
74
+     * The styles for the FlatList component in stage view.
75 75
      */
76
-    flatList: {
76
+    flatListStageView: {
77
+        flexGrow: 0
78
+    },
79
+
80
+    /**
81
+     * The styles for the FlatList component in tile view.
82
+     */
83
+    flatListTileView: {
77 84
         flex: 0
78 85
     },
79 86
 
@@ -94,13 +101,6 @@ export default {
94 101
         right: 4
95 102
     },
96 103
 
97
-    /**
98
-     * The style of the scrollview containing the remote thumbnails.
99
-     */
100
-    scrollView: {
101
-        flexGrow: 0
102
-    },
103
-
104 104
     /**
105 105
      * The style of a participant's Thumbnail which renders either the video or
106 106
      * the avatar of the associated participant.

+ 5
- 0
react/features/filmstrip/middleware.native.js Bestand weergeven

@@ -13,6 +13,11 @@ import './subscriber';
13 13
  */
14 14
 MiddlewareRegistry.register(store => next => action => {
15 15
     if (action.type === PARTICIPANT_LEFT) {
16
+        // This have to be executed before we remove the participant from features/base/participants state in order to
17
+        // remove the related thumbnail component before we need to re-render it. If we do this after next()
18
+        // we will be in sitation where the participant exists in the remoteParticipants array in features/filmstrip
19
+        // but doesn't exist in features/base/participants state which will lead to rendering a thumbnail for
20
+        // non-existing participant.
16 21
         updateRemoteParticipantsOnLeave(store, action.participant?.id);
17 22
     }
18 23
 

Laden…
Annuleren
Opslaan