Ver código fonte

[RN] Unpin participant and set last N to 1 if the filmstrip is disabled (Coding style: consistency)

master
Lyubo Marinov 7 anos atrás
pai
commit
10f72f8e40

+ 27
- 41
react/features/base/conference/middleware.js Ver arquivo

1
 // @flow
1
 // @flow
2
 
2
 
3
-import UIEvents from '../../../../service/UI/UIEvents';
4
-
5
 import {
3
 import {
6
     ACTION_PINNED,
4
     ACTION_PINNED,
7
     ACTION_UNPINNED,
5
     ACTION_UNPINNED,
18
     PIN_PARTICIPANT
16
     PIN_PARTICIPANT
19
 } from '../participants';
17
 } from '../participants';
20
 import { MiddlewareRegistry } from '../redux';
18
 import { MiddlewareRegistry } from '../redux';
19
+import UIEvents from '../../../../service/UI/UIEvents';
21
 import { TRACK_ADDED, TRACK_REMOVED } from '../tracks';
20
 import { TRACK_ADDED, TRACK_REMOVED } from '../tracks';
22
 
21
 
23
 import {
22
 import {
97
  * @param {Action} action - The redux action CONNECTION_ESTABLISHED which is
96
  * @param {Action} action - The redux action CONNECTION_ESTABLISHED which is
98
  * being dispatched in the specified store.
97
  * being dispatched in the specified store.
99
  * @private
98
  * @private
100
- * @returns {Object} The new state that is the result of the reduction of the
101
- * specified action.
99
+ * @returns {Object} The value returned by {@code next(action)}.
102
  */
100
  */
103
-function _connectionEstablished(store, next, action) {
101
+function _connectionEstablished({ dispatch }, next, action) {
104
     const result = next(action);
102
     const result = next(action);
105
 
103
 
106
     // FIXME: workaround for the web version. Currently the creation of the
104
     // FIXME: workaround for the web version. Currently the creation of the
107
     // conference is handled by /conference.js
105
     // conference is handled by /conference.js
108
     if (typeof APP === 'undefined') {
106
     if (typeof APP === 'undefined') {
109
-        store.dispatch(createConference());
107
+        dispatch(createConference());
110
     }
108
     }
111
 
109
 
112
     return result;
110
     return result;
123
  * @param {Action} action - The redux action {@link CONFERENCE_FAILED} or
121
  * @param {Action} action - The redux action {@link CONFERENCE_FAILED} or
124
  * {@link CONFERENCE_LEFT} which is being dispatched in the specified store.
122
  * {@link CONFERENCE_LEFT} which is being dispatched in the specified store.
125
  * @private
123
  * @private
126
- * @returns {Object} The new state that is the result of the reduction of the
127
- * specified action.
124
+ * @returns {Object} The value returned by {@code next(action)}.
128
  */
125
  */
129
 function _conferenceFailedOrLeft({ dispatch, getState }, next, action) {
126
 function _conferenceFailedOrLeft({ dispatch, getState }, next, action) {
130
     const result = next(action);
127
     const result = next(action);
149
  * @param {Action} action - The redux action CONFERENCE_JOINED which is being
146
  * @param {Action} action - The redux action CONFERENCE_JOINED which is being
150
  * dispatched in the specified store.
147
  * dispatched in the specified store.
151
  * @private
148
  * @private
152
- * @returns {Object} The new state that is the result of the reduction of the
153
- * specified action.
149
+ * @returns {Object} The value returned by {@code next(action)}.
154
  */
150
  */
155
-function _conferenceJoined(store, next, action) {
151
+function _conferenceJoined({ dispatch, getState }, next, action) {
156
     const result = next(action);
152
     const result = next(action);
157
-    const { audioOnly, conference }
158
-        = store.getState()['features/base/conference'];
153
+
154
+    const { audioOnly, conference } = getState()['features/base/conference'];
159
 
155
 
160
     // FIXME On Web the audio only mode for "start audio only" is toggled before
156
     // FIXME On Web the audio only mode for "start audio only" is toggled before
161
     // conference is added to the redux store ("on conference joined" action)
157
     // conference is added to the redux store ("on conference joined" action)
162
     // and the LastN value needs to be synchronized here.
158
     // and the LastN value needs to be synchronized here.
163
-    if (audioOnly && conference.getLastN() !== 0) {
164
-        store.dispatch(setLastN(0));
165
-    }
159
+    audioOnly && (conference.getLastN() !== 0) && dispatch(setLastN(0));
166
 
160
 
167
     return result;
161
     return result;
168
 }
162
 }
179
  * @param {Action} action - The redux action PIN_PARTICIPANT which is being
173
  * @param {Action} action - The redux action PIN_PARTICIPANT which is being
180
  * dispatched in the specified store.
174
  * dispatched in the specified store.
181
  * @private
175
  * @private
182
- * @returns {Object} The new state that is the result of the reduction of the
183
- * specified action.
176
+ * @returns {Object} The value returned by {@code next(action)}.
184
  */
177
  */
185
-function _pinParticipant(store, next, action) {
186
-    const state = store.getState();
178
+function _pinParticipant({ getState }, next, action) {
179
+    const state = getState();
187
     const { conference } = state['features/base/conference'];
180
     const { conference } = state['features/base/conference'];
188
 
181
 
189
     if (!conference) {
182
     if (!conference) {
248
  * @param {Action} action - The redux action SET_AUDIO_ONLY which is being
241
  * @param {Action} action - The redux action SET_AUDIO_ONLY which is being
249
  * dispatched in the specified store.
242
  * dispatched in the specified store.
250
  * @private
243
  * @private
251
- * @returns {Object} The new state that is the result of the reduction of the
252
- * specified action.
244
+ * @returns {Object} The value returned by {@code next(action)}.
253
  */
245
  */
254
 function _setAudioOnly({ dispatch, getState }, next, action) {
246
 function _setAudioOnly({ dispatch, getState }, next, action) {
255
     const result = next(action);
247
     const result = next(action);
286
  * @param {Action} action - The redux action SET_LASTN which is being dispatched
278
  * @param {Action} action - The redux action SET_LASTN which is being dispatched
287
  * in the specified store.
279
  * in the specified store.
288
  * @private
280
  * @private
289
- * @returns {Object} The new state that is the result of the reduction of the
290
- * specified action.
281
+ * @returns {Object} The value returned by {@code next(action)}.
291
  */
282
  */
292
-function _setLastN(store, next, action) {
293
-    const { conference } = store.getState()['features/base/conference'];
283
+function _setLastN({ getState }, next, action) {
284
+    const { conference } = getState()['features/base/conference'];
294
 
285
 
295
     if (conference) {
286
     if (conference) {
296
         try {
287
         try {
307
  * Sets the maximum receive video quality and will turn off audio only mode if
298
  * Sets the maximum receive video quality and will turn off audio only mode if
308
  * enabled.
299
  * enabled.
309
  *
300
  *
310
- * @param {Store} store - The Redux store in which the specified action is being
301
+ * @param {Store} store - The redux store in which the specified action is being
311
  * dispatched.
302
  * dispatched.
312
- * @param {Dispatch} next - The Redux dispatch function to dispatch the
303
+ * @param {Dispatch} next - The redux dispatch function to dispatch the
313
  * specified action to the specified store.
304
  * specified action to the specified store.
314
- * @param {Action} action - The Redux action SET_RECEIVE_VIDEO_QUALITY which is
305
+ * @param {Action} action - The redux action SET_RECEIVE_VIDEO_QUALITY which is
315
  * being dispatched in the specified store.
306
  * being dispatched in the specified store.
316
  * @private
307
  * @private
317
- * @returns {Object} The new state that is the result of the reduction of the
318
- * specified action.
308
+ * @returns {Object} The value returned by {@code next(action)}.
319
  */
309
  */
320
 function _setReceiveVideoQuality({ dispatch, getState }, next, action) {
310
 function _setReceiveVideoQuality({ dispatch, getState }, next, action) {
321
     const { audioOnly, conference } = getState()['features/base/conference'];
311
     const { audioOnly, conference } = getState()['features/base/conference'];
322
 
312
 
323
     if (conference) {
313
     if (conference) {
324
         conference.setReceiverVideoConstraint(action.receiveVideoQuality);
314
         conference.setReceiverVideoConstraint(action.receiveVideoQuality);
325
-        if (audioOnly) {
326
-            dispatch(toggleAudioOnly());
327
-        }
315
+        audioOnly && dispatch(toggleAudioOnly());
328
     }
316
     }
329
 
317
 
330
     return next(action);
318
     return next(action);
362
 /**
350
 /**
363
  * Sets the maximum receive video quality.
351
  * Sets the maximum receive video quality.
364
  *
352
  *
365
- * @param {Store} store - The Redux store in which the specified action is being
353
+ * @param {Store} store - The redux store in which the specified action is being
366
  * dispatched.
354
  * dispatched.
367
- * @param {Dispatch} next - The Redux dispatch function to dispatch the
355
+ * @param {Dispatch} next - The redux dispatch function to dispatch the
368
  * specified action to the specified store.
356
  * specified action to the specified store.
369
- * @param {Action} action - The Redux action DATA_CHANNEL_STATUS_CHANGED which
357
+ * @param {Action} action - The redux action DATA_CHANNEL_STATUS_CHANGED which
370
  * is being dispatched in the specified store.
358
  * is being dispatched in the specified store.
371
  * @private
359
  * @private
372
- * @returns {Object} The new state that is the result of the reduction of the
373
- * specified action.
360
+ * @returns {Object} The value returned by {@code next(action)}.
374
  */
361
  */
375
 function _syncReceiveVideoQuality({ getState }, next, action) {
362
 function _syncReceiveVideoQuality({ getState }, next, action) {
376
     const state = getState()['features/base/conference'];
363
     const state = getState()['features/base/conference'];
391
  * @param {Action} action - The redux action TRACK_ADDED or TRACK_REMOVED which
378
  * @param {Action} action - The redux action TRACK_ADDED or TRACK_REMOVED which
392
  * is being dispatched in the specified store.
379
  * is being dispatched in the specified store.
393
  * @private
380
  * @private
394
- * @returns {Object} The new state that is the result of the reduction of the
395
- * specified action.
381
+ * @returns {Object} The value returned by {@code next(action)}.
396
  */
382
  */
397
 function _trackAddedOrRemoved(store, next, action) {
383
 function _trackAddedOrRemoved(store, next, action) {
398
     const track = action.track;
384
     const track = action.track;

+ 78
- 34
react/features/filmstrip/middleware.js Ver arquivo

4
 import { SET_CALLEE_INFO_VISIBLE } from '../base/jwt';
4
 import { SET_CALLEE_INFO_VISIBLE } from '../base/jwt';
5
 import { pinParticipant } from '../base/participants';
5
 import { pinParticipant } from '../base/participants';
6
 import { MiddlewareRegistry } from '../base/redux';
6
 import { MiddlewareRegistry } from '../base/redux';
7
-
8
 import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
7
 import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
9
 
8
 
10
 import { SET_FILMSTRIP_ENABLED } from './actionTypes';
9
 import { SET_FILMSTRIP_ENABLED } from './actionTypes';
11
 
10
 
12
 declare var APP: Object;
11
 declare var APP: Object;
13
 
12
 
14
-MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
13
+MiddlewareRegistry.register(store => next => action => {
15
     switch (action.type) {
14
     switch (action.type) {
16
     case SET_CALLEE_INFO_VISIBLE:
15
     case SET_CALLEE_INFO_VISIBLE:
17
-        if (typeof APP !== 'undefined') {
18
-            const oldValue
19
-                = Boolean(getState()['features/base/jwt'].calleeInfoVisible);
20
-            const result = next(action);
21
-            const newValue
22
-                = Boolean(getState()['features/base/jwt'].calleeInfoVisible);
23
-
24
-            oldValue === newValue
25
-
26
-                // FIXME The following accesses the private state filmstrip of
27
-                // Filmstrip. It is written with the understanding that
28
-                // Filmstrip will be rewritten in React and, consequently, will
29
-                // not need the middleware implemented here, Filmstrip.init, and
30
-                // UI.start.
31
-                || (Filmstrip.filmstrip
32
-                    && Filmstrip.toggleFilmstrip(!newValue));
33
-
34
-            return result;
35
-        }
36
-        break;
16
+        return _setCalleeInfoVisible(store, next, action);
37
 
17
 
38
     case SET_FILMSTRIP_ENABLED:
18
     case SET_FILMSTRIP_ENABLED:
39
-        // FIXME: Only do this on mobile for now. The logic for participant
40
-        // pinning / unpinning is not on React yet so dispatching the action
41
-        // is not enough.
42
-        if (typeof APP === 'undefined') {
43
-            const { audioOnly } = getState()['features/base/conference'];
44
-            const { enabled } = action;
45
-
46
-            !enabled && dispatch(pinParticipant(null));
47
-            !audioOnly && dispatch(setLastN(enabled ? undefined : 1));
48
-        }
49
-        break;
50
-
19
+        return _setFilmstripEnabled(store, next, action);
51
     }
20
     }
52
 
21
 
53
     return next(action);
22
     return next(action);
54
 });
23
 });
24
+
25
+/**
26
+ * Notifies the feature filmstrip that the action
27
+ * {@link SET_CALLEE_INFO_VISIBLE} is being dispatched within a specific redux
28
+ * store.
29
+ *
30
+ * @param {Store} store - The redux store in which the specified action is being
31
+ * dispatched.
32
+ * @param {Dispatch} next - The redux dispatch function to dispatch the
33
+ * specified action to the specified store.
34
+ * @param {Action} action - The redux action {@code SET_CALLEE_INFO_VISIBLE}
35
+ * which is being dispatched in the specified store.
36
+ * @private
37
+ * @returns {Object} The value returned by {@code next(action)}.
38
+ */
39
+function _setCalleeInfoVisible({ getState }, next, action) {
40
+    if (typeof APP !== 'undefined') {
41
+        const oldValue
42
+            = Boolean(getState()['features/base/jwt'].calleeInfoVisible);
43
+        const result = next(action);
44
+        const newValue
45
+            = Boolean(getState()['features/base/jwt'].calleeInfoVisible);
46
+
47
+        oldValue === newValue
48
+
49
+            // FIXME The following accesses the private state filmstrip of
50
+            // Filmstrip. It is written with the understanding that Filmstrip
51
+            // will be rewritten in React and, consequently, will not need the
52
+            // middleware implemented here, Filmstrip.init, and UI.start.
53
+            || (Filmstrip.filmstrip && Filmstrip.toggleFilmstrip(!newValue));
54
+
55
+        return result;
56
+    }
57
+
58
+    return next(action);
59
+}
60
+
61
+/**
62
+ * Notifies the feature filmstrip that the action {@link SET_FILMSTRIP_ENABLED}
63
+ * is being dispatched within a specific redux store.
64
+ *
65
+ * @param {Store} store - The redux store in which the specified action is being
66
+ * dispatched.
67
+ * @param {Dispatch} next - The redux dispatch function to dispatch the
68
+ * specified action to the specified store.
69
+ * @param {Action} action - The redux action {@code SET_FILMSTRIP_ENABLED} which
70
+ * is being dispatched in the specified store.
71
+ * @private
72
+ * @returns {Object} The value returned by {@code next(action)}.
73
+ */
74
+function _setFilmstripEnabled({ dispatch, getState }, next, action) {
75
+    const result = next(action);
76
+
77
+    // FIXME The logic for participant pinning / unpinning is not on React yet
78
+    // so dispatching the action is not enough. Hence, perform the following
79
+    // only where it will be sufficient i.e. mobile.
80
+    if (typeof APP === 'undefined') {
81
+        const state = getState();
82
+        const { enabled } = state['features/filmstrip'];
83
+        const { audioOnly } = state['features/base/conference'];
84
+
85
+        enabled || dispatch(pinParticipant(null));
86
+
87
+        // FIXME Audio-only mode fiddles with lastN as well. That's why we don't
88
+        // touch lastN in audio-only mode. But it's not clear what the value of
89
+        // lastN should be upon exit from audio-only mode if the filmstrip is
90
+        // disabled already. Currently, audio-only mode will set undefined
91
+        // regardless of whether the filmstrip is disabled. But we don't have a
92
+        // practical use case in which audio-only mode is exited while the
93
+        // filmstrip is disabled.
94
+        audioOnly || dispatch(setLastN(enabled ? undefined : 1));
95
+    }
96
+
97
+    return result;
98
+}

Carregando…
Cancelar
Salvar