Sfoglia il codice sorgente

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

j8
Saúl Ibarra Corretgé 8 anni fa
parent
commit
623b7a8d6f

+ 29
- 0
react/features/base/conference/actions.js Vedi File

@@ -1,5 +1,6 @@
1 1
 import { JitsiConferenceEvents } from '../lib-jitsi-meet';
2 2
 import {
3
+    changeParticipantLastNStatus,
3 4
     dominantSpeakerChanged,
4 5
     getLocalParticipant,
5 6
     participantJoined,
@@ -52,6 +53,10 @@ function _addConferenceListeners(conference, dispatch) {
52 53
             JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED,
53 54
             (...args) => dispatch(dominantSpeakerChanged(...args)));
54 55
 
56
+    conference.on(
57
+        JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
58
+        (...args) => _lastNEndpointsChanged(dispatch, ...args));
59
+
55 60
     conference.on(
56 61
             JitsiConferenceEvents.LOCK_STATE_CHANGED,
57 62
             (...args) => dispatch(_lockStateChanged(conference, ...args)));
@@ -263,6 +268,30 @@ export function createConference() {
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 296
  * Signals that the lock state of a specific JitsiConference changed.
268 297
  *

+ 24
- 0
react/features/base/participants/actions.js Vedi File

@@ -8,6 +8,30 @@ import {
8 8
 } from './actionTypes';
9 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 36
  * Create an action for when dominant speaker changes.
13 37
  *

+ 18
- 6
react/features/base/participants/components/ParticipantView.native.js Vedi File

@@ -34,6 +34,13 @@ class ParticipantView extends Component {
34 34
          */
35 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 45
          * The video Track of the participant with {@link #participantId}.
39 46
          */
@@ -85,20 +92,23 @@ class ParticipantView extends Component {
85 92
      * @returns {ReactElement}
86 93
      */
87 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 102
         // FIXME It's currently impossible to have true as the value of
92 103
         // waitForVideoStarted because videoTrack's state videoStarted will be
93 104
         // updated only after videoTrack is rendered.
94 105
         const waitForVideoStarted = false;
95 106
         const renderVideo
96
-            = shouldRenderVideoTrack(videoTrack, waitForVideoStarted);
107
+            = shouldRenderVideoTrack(videoTrack, waitForVideoStarted)
108
+                && (typeof isInLastN === 'undefined' || isInLastN);
97 109
 
98 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 113
         return (
104 114
             <Container
@@ -158,6 +168,7 @@ function _toBoolean(value, undefinedValue) {
158 168
  * @private
159 169
  * @returns {{
160 170
  *     _avatar: string,
171
+ *     _isInLastN: boolean,
161 172
  *     _videoTrack: Track
162 173
  * }}
163 174
  */
@@ -170,6 +181,7 @@ function _mapStateToProps(state, ownProps) {
170 181
 
171 182
     return {
172 183
         _avatar: participant && getAvatarURL(participant),
184
+        _isInLastN: participant && participant.isInLastN,
173 185
         _videoTrack:
174 186
             getTrackByMediaTypeAndParticipant(
175 187
                 state['features/base/tracks'],

+ 10
- 2
react/features/base/participants/reducer.js Vedi File

@@ -71,8 +71,15 @@ function _participant(state, action) {
71 71
 
72 72
     case PARTICIPANT_JOINED: {
73 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 83
         let { avatarID, id, name } = participant;
77 84
 
78 85
         // avatarID
@@ -103,6 +110,7 @@ function _participant(state, action) {
103 110
             dominantSpeaker: dominantSpeaker || false,
104 111
             email,
105 112
             id,
113
+            isInLastN,
106 114
             local: local || false,
107 115
             name,
108 116
             pinned: pinned || false,

Loading…
Annulla
Salva