Bladeren bron

Coding style

master
Lyubo Marinov 7 jaren geleden
bovenliggende
commit
d521deecc4
1 gewijzigde bestanden met toevoegingen van 30 en 24 verwijderingen
  1. 30
    24
      react/features/base/media/middleware.js

+ 30
- 24
react/features/base/media/middleware.js Bestand weergeven

@@ -46,52 +46,58 @@ MiddlewareRegistry.register(store => next => action => {
46 46
  * specified {@code action}.
47 47
  */
48 48
 function _setRoom({ dispatch, getState }, next, action) {
49
+    const { room } = action;
50
+
51
+    // Read the config.
52
+
49 53
     const state = getState();
54
+    let urlParams;
50 55
     let audioMuted;
51
-    let audioOnly;
52 56
     let videoMuted;
53 57
 
54
-    if (action.room) {
55
-        // The Jitsi Meet client may override the Jitsi Meet deployment on the
56
-        // subject of these:
57
-        //  - startAudioOnly
58
-        //  - startWithAudioMuted
59
-        //  - startWithVideoMuted
60
-        // in the (location) URL.
61
-        const urlParams
58
+    if (room) {
59
+        // The Jitsi Meet client may override the Jitsi Meet deployment in the
60
+        // (location) URL on the subject of the following:
61
+        // - startAudioOnly
62
+        // - startWithAudioMuted
63
+        // - startWithVideoMuted
64
+        urlParams
62 65
             = parseURLParams(state['features/base/connection'].locationURL);
63 66
 
64 67
         audioMuted = urlParams['config.startWithAudioMuted'];
65
-        audioOnly = urlParams['config.startAudioOnly'];
66 68
         videoMuted = urlParams['config.startWithVideoMuted'];
67 69
     }
68 70
 
69
-    // Of course, the Jitsi Meet deployment may define those options through
70
-    // config.js which should be respected if the client did not override it.
71
+    // Of course, the Jitsi Meet deployment defines config.js which should be
72
+    // respected if the client did not override it.
71 73
     const config = state['features/base/config'];
72 74
 
73 75
     typeof audioMuted === 'undefined'
74 76
         && (audioMuted = config.startWithAudioMuted);
75
-    typeof audioOnly === 'undefined'
76
-        && (audioOnly = config.startAudioOnly);
77 77
     typeof videoMuted === 'undefined'
78 78
         && (videoMuted = config.startWithVideoMuted);
79 79
 
80
-    // Apply options.
81
-    audioMuted = Boolean(audioMuted);
82
-    audioOnly = Boolean(audioOnly);
83
-    videoMuted = Boolean(videoMuted);
80
+    // Apply the config.
84 81
 
85 82
     // Unconditionally express the desires/expectations/intents of the app and
86 83
     // the user i.e. the state of base/media. Eventually, practice/reality i.e.
87 84
     // the state of base/tracks will or will not agree with the desires.
88
-    dispatch(setAudioMuted(audioMuted));
85
+    dispatch(setAudioMuted(Boolean(audioMuted)));
89 86
     dispatch(setCameraFacingMode(CAMERA_FACING_MODE.USER));
90
-    dispatch(setVideoMuted(videoMuted));
91
-
92
-    // Apply starAudioOnly if we are joining a conference
93
-    if (action.room) {
94
-        dispatch(setAudioOnly(audioOnly));
87
+    dispatch(setVideoMuted(Boolean(videoMuted)));
88
+
89
+    // config.startAudioOnly
90
+    //
91
+    // FIXME Technically, the audio-only feature is owned by base/conference,
92
+    // not base/media so the following should be in base/conference.
93
+    // Practically, I presume it was easier to write the source code here
94
+    // because it looks like config.startWithAudioMuted and
95
+    // config.startWithVideoMuted.
96
+    if (room) {
97
+        let audioOnly = urlParams && urlParams['config.startAudioOnly'];
98
+
99
+        typeof audioOnly === 'undefined' && (audioOnly = config.startAudioOnly);
100
+        dispatch(setAudioOnly(Boolean(audioOnly)));
95 101
     }
96 102
 
97 103
     return next(action);

Laden…
Annuleren
Opslaan