Bladeren bron

[RN] Show avatar if a participant is not in last N

master
Saúl Ibarra Corretgé 8 jaren geleden
bovenliggende
commit
623b7a8d6f

+ 29
- 0
react/features/base/conference/actions.js Bestand weergeven

1
 import { JitsiConferenceEvents } from '../lib-jitsi-meet';
1
 import { JitsiConferenceEvents } from '../lib-jitsi-meet';
2
 import {
2
 import {
3
+    changeParticipantLastNStatus,
3
     dominantSpeakerChanged,
4
     dominantSpeakerChanged,
4
     getLocalParticipant,
5
     getLocalParticipant,
5
     participantJoined,
6
     participantJoined,
52
             JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED,
53
             JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED,
53
             (...args) => dispatch(dominantSpeakerChanged(...args)));
54
             (...args) => dispatch(dominantSpeakerChanged(...args)));
54
 
55
 
56
+    conference.on(
57
+        JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
58
+        (...args) => _lastNEndpointsChanged(dispatch, ...args));
59
+
55
     conference.on(
60
     conference.on(
56
             JitsiConferenceEvents.LOCK_STATE_CHANGED,
61
             JitsiConferenceEvents.LOCK_STATE_CHANGED,
57
             (...args) => dispatch(_lockStateChanged(conference, ...args)));
62
             (...args) => dispatch(_lockStateChanged(conference, ...args)));
263
     };
268
     };
264
 }
269
 }
265
 
270
 
271
+/**
272
+ * Handles the lastN status changes for participants in the current conference.
273
+ * Signals that a participant's lastN status has changed, for each participant
274
+ * who entered or left the last N set.
275
+ *
276
+ * @param {Dispatch} dispatch - Redux dispatch function.
277
+ * @param {Array} leavingIds - Ids of participants who are leaving the last N
278
+ * set.
279
+ * @param {Array} enteringIds - Ids of participants who are entering the last N
280
+ * set.
281
+ * @returns {void}
282
+ *
283
+ * @private
284
+ */
285
+function _lastNEndpointsChanged(dispatch, leavingIds = [], enteringIds = []) {
286
+    for (const id of leavingIds) {
287
+        dispatch(changeParticipantLastNStatus(id, false));
288
+    }
289
+
290
+    for (const id of enteringIds) {
291
+        dispatch(changeParticipantLastNStatus(id, true));
292
+    }
293
+}
294
+
266
 /**
295
 /**
267
  * Signals that the lock state of a specific JitsiConference changed.
296
  * Signals that the lock state of a specific JitsiConference changed.
268
  *
297
  *

+ 24
- 0
react/features/base/participants/actions.js Bestand weergeven

8
 } from './actionTypes';
8
 } from './actionTypes';
9
 import { getLocalParticipant } from './functions';
9
 import { getLocalParticipant } from './functions';
10
 
10
 
11
+/**
12
+ * Action to update a participant's lastN status.
13
+ *
14
+ * @param {string} id - Participant's ID.
15
+ * @param {boolean} isInLastN - True if the participant is in the lastN
16
+ * endpoints set, false otherwise.
17
+ * @returns {{
18
+ *     type: PARTICIPANT_UPDATED,
19
+ *     participant: {
20
+ *         id: string,
21
+ *         isInLastN: boolean
22
+ *     }
23
+ * }}
24
+ */
25
+export function changeParticipantLastNStatus(id, isInLastN) {
26
+    return {
27
+        type: PARTICIPANT_UPDATED,
28
+        participant: {
29
+            id,
30
+            isInLastN
31
+        }
32
+    };
33
+}
34
+
11
 /**
35
 /**
12
  * Create an action for when dominant speaker changes.
36
  * Create an action for when dominant speaker changes.
13
  *
37
  *

+ 18
- 6
react/features/base/participants/components/ParticipantView.native.js Bestand weergeven

34
          */
34
          */
35
         _avatar: React.PropTypes.string,
35
         _avatar: React.PropTypes.string,
36
 
36
 
37
+        /**
38
+         * True if the participant is in the last N endpoints set, false if he
39
+         * isn't. If undefined, we have no indication, so the same course of
40
+         * action as true is taken.
41
+         */
42
+        _isInLastN: React.PropTypes.bool,
43
+
37
         /**
44
         /**
38
          * The video Track of the participant with {@link #participantId}.
45
          * The video Track of the participant with {@link #participantId}.
39
          */
46
          */
85
      * @returns {ReactElement}
92
      * @returns {ReactElement}
86
      */
93
      */
87
     render() {
94
     render() {
88
-        // Is the video to be rendered?
89
-        const videoTrack = this.props._videoTrack;
95
+        const {
96
+            _avatar: avatar,
97
+            _isInLastN: isInLastN,
98
+            _videoTrack: videoTrack
99
+        } = this.props;
90
 
100
 
101
+        // Is the video to be rendered?
91
         // FIXME It's currently impossible to have true as the value of
102
         // FIXME It's currently impossible to have true as the value of
92
         // waitForVideoStarted because videoTrack's state videoStarted will be
103
         // waitForVideoStarted because videoTrack's state videoStarted will be
93
         // updated only after videoTrack is rendered.
104
         // updated only after videoTrack is rendered.
94
         const waitForVideoStarted = false;
105
         const waitForVideoStarted = false;
95
         const renderVideo
106
         const renderVideo
96
-            = shouldRenderVideoTrack(videoTrack, waitForVideoStarted);
107
+            = shouldRenderVideoTrack(videoTrack, waitForVideoStarted)
108
+                && (typeof isInLastN === 'undefined' || isInLastN);
97
 
109
 
98
         // Is the avatar to be rendered?
110
         // Is the avatar to be rendered?
99
-        const avatar = this.props._avatar;
100
-        const renderAvatar
101
-            = !renderVideo && typeof avatar !== 'undefined' && avatar !== '';
111
+        const renderAvatar = Boolean(!renderVideo && avatar);
102
 
112
 
103
         return (
113
         return (
104
             <Container
114
             <Container
158
  * @private
168
  * @private
159
  * @returns {{
169
  * @returns {{
160
  *     _avatar: string,
170
  *     _avatar: string,
171
+ *     _isInLastN: boolean,
161
  *     _videoTrack: Track
172
  *     _videoTrack: Track
162
  * }}
173
  * }}
163
  */
174
  */
170
 
181
 
171
     return {
182
     return {
172
         _avatar: participant && getAvatarURL(participant),
183
         _avatar: participant && getAvatarURL(participant),
184
+        _isInLastN: participant && participant.isInLastN,
173
         _videoTrack:
185
         _videoTrack:
174
             getTrackByMediaTypeAndParticipant(
186
             getTrackByMediaTypeAndParticipant(
175
                 state['features/base/tracks'],
187
                 state['features/base/tracks'],

+ 10
- 2
react/features/base/participants/reducer.js Bestand weergeven

71
 
71
 
72
     case PARTICIPANT_JOINED: {
72
     case PARTICIPANT_JOINED: {
73
         const participant = action.participant; // eslint-disable-line no-shadow
73
         const participant = action.participant; // eslint-disable-line no-shadow
74
-        const { avatarURL, dominantSpeaker, email, local, pinned, role }
75
-            = participant;
74
+        const {
75
+            avatarURL,
76
+            dominantSpeaker,
77
+            email,
78
+            isInLastN,
79
+            local,
80
+            pinned,
81
+            role
82
+        } = participant;
76
         let { avatarID, id, name } = participant;
83
         let { avatarID, id, name } = participant;
77
 
84
 
78
         // avatarID
85
         // avatarID
103
             dominantSpeaker: dominantSpeaker || false,
110
             dominantSpeaker: dominantSpeaker || false,
104
             email,
111
             email,
105
             id,
112
             id,
113
+            isInLastN,
106
             local: local || false,
114
             local: local || false,
107
             name,
115
             name,
108
             pinned: pinned || false,
116
             pinned: pinned || false,

Laden…
Annuleren
Opslaan