瀏覽代碼

Coding style

master
Lyubo Marinov 7 年之前
父節點
當前提交
d521deecc4
共有 1 個檔案被更改,包括 30 行新增24 行删除
  1. 30
    24
      react/features/base/media/middleware.js

+ 30
- 24
react/features/base/media/middleware.js 查看文件

46
  * specified {@code action}.
46
  * specified {@code action}.
47
  */
47
  */
48
 function _setRoom({ dispatch, getState }, next, action) {
48
 function _setRoom({ dispatch, getState }, next, action) {
49
+    const { room } = action;
50
+
51
+    // Read the config.
52
+
49
     const state = getState();
53
     const state = getState();
54
+    let urlParams;
50
     let audioMuted;
55
     let audioMuted;
51
-    let audioOnly;
52
     let videoMuted;
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
             = parseURLParams(state['features/base/connection'].locationURL);
65
             = parseURLParams(state['features/base/connection'].locationURL);
63
 
66
 
64
         audioMuted = urlParams['config.startWithAudioMuted'];
67
         audioMuted = urlParams['config.startWithAudioMuted'];
65
-        audioOnly = urlParams['config.startAudioOnly'];
66
         videoMuted = urlParams['config.startWithVideoMuted'];
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
     const config = state['features/base/config'];
73
     const config = state['features/base/config'];
72
 
74
 
73
     typeof audioMuted === 'undefined'
75
     typeof audioMuted === 'undefined'
74
         && (audioMuted = config.startWithAudioMuted);
76
         && (audioMuted = config.startWithAudioMuted);
75
-    typeof audioOnly === 'undefined'
76
-        && (audioOnly = config.startAudioOnly);
77
     typeof videoMuted === 'undefined'
77
     typeof videoMuted === 'undefined'
78
         && (videoMuted = config.startWithVideoMuted);
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
     // Unconditionally express the desires/expectations/intents of the app and
82
     // Unconditionally express the desires/expectations/intents of the app and
86
     // the user i.e. the state of base/media. Eventually, practice/reality i.e.
83
     // the user i.e. the state of base/media. Eventually, practice/reality i.e.
87
     // the state of base/tracks will or will not agree with the desires.
84
     // the state of base/tracks will or will not agree with the desires.
88
-    dispatch(setAudioMuted(audioMuted));
85
+    dispatch(setAudioMuted(Boolean(audioMuted)));
89
     dispatch(setCameraFacingMode(CAMERA_FACING_MODE.USER));
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
     return next(action);
103
     return next(action);

Loading…
取消
儲存