Kaynağa Gözat

Flow, coding style

master
Lyubo Marinov 7 yıl önce
ebeveyn
işleme
2d73e9ace4

+ 1
- 1
react/features/base/conference/middleware.js Dosyayı Görüntüle

@@ -185,7 +185,7 @@ function _pinParticipant(store, next, action) {
185 185
         let videoType;
186 186
 
187 187
         if ((participantById && participantById.local)
188
-            || (!id && pinnedParticipant && pinnedParticipant.local)) {
188
+                || (!id && pinnedParticipant && pinnedParticipant.local)) {
189 189
             videoType = 'local';
190 190
         } else {
191 191
             videoType = 'remote';

+ 33
- 32
react/features/base/participants/actions.js Dosyayı Görüntüle

@@ -32,6 +32,22 @@ export function dominantSpeakerChanged(id) {
32 32
     };
33 33
 }
34 34
 
35
+/**
36
+ * Create an action for removing a participant from the conference.
37
+ *
38
+ * @param {string} id - Participant's ID.
39
+ * @returns {{
40
+ *     type: KICK_PARTICIPANT,
41
+ *     id: string
42
+ * }}
43
+ */
44
+export function kickParticipant(id) {
45
+    return {
46
+        type: KICK_PARTICIPANT,
47
+        id
48
+    };
49
+}
50
+
35 51
 /**
36 52
  * Creates an action to signal the connection status of the local participant
37 53
  * has changed.
@@ -47,27 +63,12 @@ export function localParticipantConnectionStatusChanged(connectionStatus) {
47 63
 
48 64
         if (participant) {
49 65
             return dispatch(participantConnectionStatusChanged(
50
-                participant.id, connectionStatus));
66
+                participant.id,
67
+                connectionStatus));
51 68
         }
52 69
     };
53 70
 }
54 71
 
55
-/**
56
- * Create an action for removing a participant from the conference.
57
- *
58
- * @param {string} id - Participant's ID.
59
- * @returns {{
60
- *     type: KICK_PARTICIPANT,
61
- *     id: string
62
- * }}
63
- */
64
-export function kickParticipant(id) {
65
-    return {
66
-        type: KICK_PARTICIPANT,
67
-        id
68
-    };
69
-}
70
-
71 72
 /**
72 73
  * Action to signal that the ID of local participant has changed. It happens
73 74
  * when the local participant joins a new conference or leaves an existing
@@ -106,6 +107,21 @@ export function localParticipantJoined(participant = {}) {
106 107
     });
107 108
 }
108 109
 
110
+/**
111
+ * Action to remove a local participant.
112
+ *
113
+ * @returns {Function}
114
+ */
115
+export function localParticipantLeft() {
116
+    return (dispatch, getState) => {
117
+        const participant = getLocalParticipant(getState);
118
+
119
+        if (participant) {
120
+            return dispatch(participantLeft(participant.id));
121
+        }
122
+    };
123
+}
124
+
109 125
 /**
110 126
  * Action to signal the role of the local participant has changed. It can happen
111 127
  * when the participant has joined a conference, even before a non-default local
@@ -164,21 +180,6 @@ export function participantConnectionStatusChanged(id, connectionStatus) {
164 180
     };
165 181
 }
166 182
 
167
-/**
168
- * Action to remove a local participant.
169
- *
170
- * @returns {Function}
171
- */
172
-export function localParticipantLeft() {
173
-    return (dispatch, getState) => {
174
-        const participant = getLocalParticipant(getState);
175
-
176
-        if (participant) {
177
-            return dispatch(participantLeft(participant.id));
178
-        }
179
-    };
180
-}
181
-
182 183
 /**
183 184
  * Action to signal that a participant's display name has changed.
184 185
  *

+ 14
- 12
react/features/large-video/actions.js Dosyayı Görüntüle

@@ -110,33 +110,35 @@ function _electLastVisibleRemoteVideo(tracks) {
110 110
  * @returns {(string|undefined)}
111 111
  */
112 112
 function _electParticipantInLargeVideo(state) {
113
-    // First get the pinned participant. If a participant is pinned, they will
114
-    // be shown in the LargeVideo.
113
+    // 1. If a participant is pinned, they will be shown in the LargeVideo (
114
+    //    regardless of whether they are local or remote).
115 115
     const participants = state['features/base/participants'];
116 116
     let participant = participants.find(p => p.pinned);
117 117
     let id = participant && participant.id;
118 118
 
119 119
     if (!id) {
120
-        // No participant is pinned so get the dominant speaker. But the local
121
-        // participant won't be displayed in LargeVideo even if he/she is the
122
-        // dominant speaker.
120
+        // 2. No participant is pinned so get the dominant speaker. But the
121
+        //    local participant won't be displayed in LargeVideo even if she is
122
+        //    the dominant speaker.
123 123
         participant = participants.find(p => p.dominantSpeaker && !p.local);
124 124
         id = participant && participant.id;
125 125
 
126 126
         if (!id) {
127
-            // There is no dominant speaker so select the participant which last
128
-            // had visible video (excluding ourselves).
127
+            // 3. There is no dominant speaker so select the remote participant
128
+            //    who last had visible video.
129 129
             const tracks = state['features/base/tracks'];
130 130
             const videoTrack = _electLastVisibleRemoteVideo(tracks);
131 131
 
132 132
             id = videoTrack && videoTrack.participantId;
133 133
 
134 134
             if (!id) {
135
-                // It's possible there is no participant with visible video,
136
-                // this can happen for a number or reasons:
137
-                //  - there is only one participant (the local user)
138
-                //  - other participants joined with video muted
139
-                // As a last resort, pick the last participant.
135
+                // 4. It's possible there is no participant with visible video.
136
+                //    This can happen for a number of reasons:
137
+                //    - there is only one participant (i.e. the local user),
138
+                //    - other participants joined with video muted.
139
+                //    As a last resort, pick the last participant who joined the
140
+                //    conference (regardless of whether they are local or
141
+                //    remote).
140 142
                 participant = participants[participants.length - 1];
141 143
                 id = participant && participant.id;
142 144
             }

+ 4
- 6
react/features/large-video/middleware.js Dosyayı Görüntüle

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import {
2 4
     DOMINANT_SPEAKER_CHANGED,
3 5
     PARTICIPANT_JOINED,
@@ -12,10 +14,7 @@ import {
12 14
     TRACK_UPDATED
13 15
 } from '../base/tracks';
14 16
 
15
-import {
16
-    selectParticipant,
17
-    selectParticipantInLargeVideo
18
-} from './actions';
17
+import { selectParticipant, selectParticipantInLargeVideo } from './actions';
19 18
 
20 19
 /**
21 20
  * Middleware that catches actions related to participants and tracks and
@@ -37,7 +36,7 @@ MiddlewareRegistry.register(store => next => action => {
37 36
         store.dispatch(selectParticipantInLargeVideo());
38 37
         break;
39 38
 
40
-    case TRACK_UPDATED: {
39
+    case TRACK_UPDATED:
41 40
         // In order to minimize re-calculations, we need to select participant
42 41
         // only if the videoType of the current participant rendered in
43 42
         // LargeVideo has changed.
@@ -54,7 +53,6 @@ MiddlewareRegistry.register(store => next => action => {
54 53
         }
55 54
         break;
56 55
     }
57
-    }
58 56
 
59 57
     return result;
60 58
 });

+ 2
- 0
react/features/large-video/reducer.js Dosyayı Görüntüle

@@ -1,3 +1,5 @@
1
+// @flow
2
+
1 3
 import { PARTICIPANT_ID_CHANGED } from '../base/participants';
2 4
 import { ReducerRegistry } from '../base/redux';
3 5
 

Loading…
İptal
Kaydet