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

thumbnail: use a functional component

Simplifies the code a bit, and we use no lifecycle methods.
j8
Saúl Ibarra Corretgé 5 роки тому
джерело
коміт
bcc1be675f

+ 78
- 85
react/features/filmstrip/components/native/Thumbnail.js Переглянути файл

@@ -1,6 +1,6 @@
1 1
 // @flow
2 2
 
3
-import React, { Component } from 'react';
3
+import React from 'react';
4 4
 import { View } from 'react-native';
5 5
 import type { Dispatch } from 'redux';
6 6
 
@@ -111,93 +111,86 @@ type Props = {
111 111
 /**
112 112
  * React component for video thumbnail.
113 113
  *
114
- * @extends Component
114
+ * @param {Props} props - Properties passed to this functional component.
115
+ * @returns {Component} - A React component.
115 116
  */
116
-class Thumbnail extends Component<Props> {
117
-    /**
118
-     * Implements React's {@link Component#render()}.
119
-     *
120
-     * @inheritdoc
121
-     * @returns {ReactElement}
122
-     */
123
-    render() {
124
-        const {
125
-            _audioMuted: audioMuted,
126
-            _largeVideo: largeVideo,
127
-            _onClick,
128
-            _onShowRemoteVideoMenu,
129
-            _renderDominantSpeakerIndicator: renderDominantSpeakerIndicator,
130
-            _renderModeratorIndicator: renderModeratorIndicator,
131
-            _styles,
132
-            _videoTrack: videoTrack,
133
-            disableTint,
134
-            participant,
135
-            renderDisplayName,
136
-            tileView
137
-        } = this.props;
138
-
139
-        const participantId = participant.id;
140
-        const participantInLargeVideo
141
-            = participantId === largeVideo.participantId;
142
-        const videoMuted = !videoTrack || videoTrack.muted;
143
-        const isScreenShare = videoTrack && videoTrack.videoType === VIDEO_TYPE.DESKTOP;
144
-
145
-        return (
146
-            <Container
147
-                onClick = { _onClick }
148
-                onLongPress = { participant.local ? undefined : _onShowRemoteVideoMenu }
117
+function Thumbnail(props: Props) {
118
+    const {
119
+        _audioMuted: audioMuted,
120
+        _largeVideo: largeVideo,
121
+        _onClick,
122
+        _onShowRemoteVideoMenu,
123
+        _renderDominantSpeakerIndicator: renderDominantSpeakerIndicator,
124
+        _renderModeratorIndicator: renderModeratorIndicator,
125
+        _styles,
126
+        _videoTrack: videoTrack,
127
+        disableTint,
128
+        participant,
129
+        renderDisplayName,
130
+        tileView
131
+    } = props;
132
+
133
+    const participantId = participant.id;
134
+    const participantInLargeVideo
135
+        = participantId === largeVideo.participantId;
136
+    const videoMuted = !videoTrack || videoTrack.muted;
137
+    const isScreenShare = videoTrack && videoTrack.videoType === VIDEO_TYPE.DESKTOP;
138
+
139
+    return (
140
+        <Container
141
+            onClick = { _onClick }
142
+            onLongPress = { participant.local ? undefined : _onShowRemoteVideoMenu }
143
+            style = { [
144
+                styles.thumbnail,
145
+                participant.pinned && !tileView
146
+                    ? _styles.thumbnailPinned : null,
147
+                this.props.styleOverrides || null
148
+            ] }
149
+            touchFeedback = { false }>
150
+
151
+            <ParticipantView
152
+                avatarSize = { AVATAR_SIZE }
153
+                disableVideo = { isScreenShare }
154
+                participantId = { participantId }
155
+                style = { _styles.participantViewStyle }
156
+                tintEnabled = { participantInLargeVideo && !disableTint }
157
+                tintStyle = { _styles.activeThumbnailTint }
158
+                zOrder = { 1 } />
159
+
160
+            { renderDisplayName && <DisplayNameLabel participantId = { participantId } /> }
161
+
162
+            { renderModeratorIndicator
163
+                && <View style = { styles.moderatorIndicatorContainer }>
164
+                    <ModeratorIndicator />
165
+                </View> }
166
+
167
+            <View
149 168
                 style = { [
150
-                    styles.thumbnail,
151
-                    participant.pinned && !tileView
152
-                        ? _styles.thumbnailPinned : null,
153
-                    this.props.styleOverrides || null
154
-                ] }
155
-                touchFeedback = { false }>
156
-
157
-                <ParticipantView
158
-                    avatarSize = { AVATAR_SIZE }
159
-                    disableVideo = { isScreenShare }
160
-                    participantId = { participantId }
161
-                    style = { _styles.participantViewStyle }
162
-                    tintEnabled = { participantInLargeVideo && !disableTint }
163
-                    tintStyle = { _styles.activeThumbnailTint }
164
-                    zOrder = { 1 } />
165
-
166
-                { renderDisplayName && <DisplayNameLabel participantId = { participantId } /> }
167
-
168
-                { renderModeratorIndicator
169
-                    && <View style = { styles.moderatorIndicatorContainer }>
170
-                        <ModeratorIndicator />
171
-                    </View> }
172
-
173
-                <View
174
-                    style = { [
175
-                        styles.thumbnailTopIndicatorContainer,
176
-                        styles.thumbnailTopLeftIndicatorContainer
177
-                    ] }>
178
-                    <RaisedHandIndicator participantId = { participant.id } />
179
-                    { renderDominantSpeakerIndicator && <DominantSpeakerIndicator /> }
180
-                </View>
181
-
182
-                <View
183
-                    style = { [
184
-                        styles.thumbnailTopIndicatorContainer,
185
-                        styles.thumbnailTopRightIndicatorContainer
186
-                    ] }>
187
-                    <ConnectionIndicator participantId = { participant.id } />
188
-                </View>
189
-
190
-                <Container style = { styles.thumbnailIndicatorContainer }>
191
-                    { audioMuted
192
-                        && <AudioMutedIndicator /> }
193
-
194
-                    { videoMuted
195
-                        && <VideoMutedIndicator /> }
196
-                </Container>
197
-
169
+                    styles.thumbnailTopIndicatorContainer,
170
+                    styles.thumbnailTopLeftIndicatorContainer
171
+                ] }>
172
+                <RaisedHandIndicator participantId = { participant.id } />
173
+                { renderDominantSpeakerIndicator && <DominantSpeakerIndicator /> }
174
+            </View>
175
+
176
+            <View
177
+                style = { [
178
+                    styles.thumbnailTopIndicatorContainer,
179
+                    styles.thumbnailTopRightIndicatorContainer
180
+                ] }>
181
+                <ConnectionIndicator participantId = { participant.id } />
182
+            </View>
183
+
184
+            <Container style = { styles.thumbnailIndicatorContainer }>
185
+                { audioMuted
186
+                    && <AudioMutedIndicator /> }
187
+
188
+                { videoMuted
189
+                    && <VideoMutedIndicator /> }
198 190
             </Container>
199
-        );
200
-    }
191
+
192
+        </Container>
193
+    );
201 194
 }
202 195
 
203 196
 /**

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