瀏覽代碼

Coding style

j8
Lyubo Marinov 8 年之前
父節點
當前提交
90e7804834
共有 1 個檔案被更改,包括 28 行新增36 行删除
  1. 28
    36
      react/features/toolbox/middleware.js

+ 28
- 36
react/features/toolbox/middleware.js 查看文件

3
 import {
3
 import {
4
     MEDIA_TYPE,
4
     MEDIA_TYPE,
5
     SET_AUDIO_AVAILABLE,
5
     SET_AUDIO_AVAILABLE,
6
-    SET_VIDEO_AVAILABLE } from '../base/media';
6
+    SET_VIDEO_AVAILABLE
7
+} from '../base/media';
7
 import { MiddlewareRegistry } from '../base/redux';
8
 import { MiddlewareRegistry } from '../base/redux';
8
 import { isLocalTrackMuted, TRACK_UPDATED } from '../base/tracks';
9
 import { isLocalTrackMuted, TRACK_UPDATED } from '../base/tracks';
9
 
10
 
26
         break;
27
         break;
27
     }
28
     }
28
 
29
 
30
+    case SET_AUDIO_AVAILABLE:
31
+        return _setMediaAvailableOrMuted(store, next, action);
32
+
29
     case SET_TOOLBOX_TIMEOUT: {
33
     case SET_TOOLBOX_TIMEOUT: {
30
         const { timeoutID } = store.getState()['features/toolbox'];
34
         const { timeoutID } = store.getState()['features/toolbox'];
31
         const { handler, timeoutMS } = action;
35
         const { handler, timeoutMS } = action;
37
         break;
41
         break;
38
     }
42
     }
39
 
43
 
40
-    case SET_AUDIO_AVAILABLE: {
44
+    case SET_VIDEO_AVAILABLE:
41
         return _setMediaAvailableOrMuted(store, next, action);
45
         return _setMediaAvailableOrMuted(store, next, action);
42
-    }
43
 
46
 
44
-    case SET_VIDEO_AVAILABLE: {
45
-        return _setMediaAvailableOrMuted(store, next, action);
46
-    }
47
-
48
-    case TRACK_UPDATED: {
47
+    case TRACK_UPDATED:
49
         if (action.track.jitsiTrack.isLocal()) {
48
         if (action.track.jitsiTrack.isLocal()) {
50
             return _setMediaAvailableOrMuted(store, next, action);
49
             return _setMediaAvailableOrMuted(store, next, action);
51
         }
50
         }
52
         break;
51
         break;
53
     }
52
     }
54
 
53
 
55
-    }
56
-
57
     return next(action);
54
     return next(action);
58
 });
55
 });
59
 
56
 
60
 /**
57
 /**
61
  * Adjusts the state of toolbar's microphone or camera button.
58
  * Adjusts the state of toolbar's microphone or camera button.
62
  *
59
  *
63
- * @param {Store} store - The Redux store instance.
60
+ * @param {Store} store - The redux store.
64
  * @param {Function} next - The redux function to continue dispatching the
61
  * @param {Function} next - The redux function to continue dispatching the
65
  * specified {@code action} in the specified {@code store}.
62
  * specified {@code action} in the specified {@code store}.
66
- * @param {Object} action - SET_AUDIO_AVAILABLE, SET_VIDEO_AVAILABLE or
67
- * TRACK_UPDATED.
68
- *
63
+ * @param {Object} action - <tt>SET_AUDIO_AVAILABLE</tt>,
64
+ * <tt>SET_VIDEO_AVAILABLE</tt>, or <tt>TRACK_UPDATED</tt>.
69
  * @returns {*}
65
  * @returns {*}
70
  */
66
  */
71
 function _setMediaAvailableOrMuted({ dispatch, getState }, next, action) {
67
 function _setMediaAvailableOrMuted({ dispatch, getState }, next, action) {
74
     let mediaType;
70
     let mediaType;
75
 
71
 
76
     switch (action.type) {
72
     switch (action.type) {
77
-    case SET_AUDIO_AVAILABLE: {
73
+    case SET_AUDIO_AVAILABLE:
78
         mediaType = MEDIA_TYPE.AUDIO;
74
         mediaType = MEDIA_TYPE.AUDIO;
79
         break;
75
         break;
80
-    }
81
 
76
 
82
-    case SET_VIDEO_AVAILABLE: {
77
+    case SET_VIDEO_AVAILABLE:
83
         mediaType = MEDIA_TYPE.VIDEO;
78
         mediaType = MEDIA_TYPE.VIDEO;
84
         break;
79
         break;
85
-    }
86
 
80
 
87
-    case TRACK_UPDATED: {
81
+    case TRACK_UPDATED:
88
         mediaType
82
         mediaType
89
             = action.track.jitsiTrack.isAudioTrack()
83
             = action.track.jitsiTrack.isAudioTrack()
90
-                ? MEDIA_TYPE.AUDIO : MEDIA_TYPE.VIDEO;
84
+                ? MEDIA_TYPE.AUDIO
85
+                : MEDIA_TYPE.VIDEO;
91
         break;
86
         break;
92
-    }
93
 
87
 
94
-    default: {
88
+    default:
95
         throw new Error(`Unsupported action ${action}`);
89
         throw new Error(`Unsupported action ${action}`);
96
     }
90
     }
97
 
91
 
98
-    }
99
-
100
-    const mediaState = getState()['features/base/media'];
101
-    const { available }
102
-        = mediaType === MEDIA_TYPE.AUDIO
103
-            ? mediaState.audio : mediaState.video;
92
+    const state = getState();
93
+    const { audio, video } = state['features/base/media'];
94
+    const { available } = mediaType === MEDIA_TYPE.AUDIO ? audio : video;
104
     const i18nKey
95
     const i18nKey
105
         = mediaType === MEDIA_TYPE.AUDIO
96
         = mediaType === MEDIA_TYPE.AUDIO
106
             ? available ? 'mute' : 'micDisabled'
97
             ? available ? 'mute' : 'micDisabled'
107
             : available ? 'videomute' : 'cameraDisabled';
98
             : available ? 'videomute' : 'cameraDisabled';
108
-
109
-    const tracks = getState()['features/base/tracks'];
99
+    const tracks = state['features/base/tracks'];
110
     const muted = isLocalTrackMuted(tracks, mediaType);
100
     const muted = isLocalTrackMuted(tracks, mediaType);
111
 
101
 
112
-    dispatch(setToolbarButton(
113
-        mediaType === MEDIA_TYPE.AUDIO ? 'microphone' : 'camera', {
114
-            enabled: available,
115
-            i18n: `[content]toolbar.${i18nKey}`,
116
-            toggled: available ? muted : true
117
-        }));
102
+    dispatch(
103
+        setToolbarButton(
104
+            mediaType === MEDIA_TYPE.AUDIO ? 'microphone' : 'camera',
105
+            {
106
+                enabled: available,
107
+                i18n: `[content]toolbar.${i18nKey}`,
108
+                toggled: available ? muted : true
109
+            }));
118
 
110
 
119
     return result;
111
     return result;
120
 }
112
 }

Loading…
取消
儲存