Parcourir la source

Consistent formatting

j8
Lyubo Marinov il y a 7 ans
Parent
révision
7f041170f7

+ 3
- 9
conference.js Voir le fichier

@@ -29,15 +29,11 @@ import {
29 29
     EMAIL_COMMAND,
30 30
     lockStateChanged
31 31
 } from './react/features/base/conference';
32
-import {
33
-    updateDeviceList
34
-} from './react/features/base/devices';
32
+import { updateDeviceList } from './react/features/base/devices';
35 33
 import {
36 34
     isFatalJitsiConnectionError
37 35
 } from './react/features/base/lib-jitsi-meet';
38
-import {
39
-    setVideoAvailable
40
-} from './react/features/base/media';
36
+import { setVideoAvailable } from './react/features/base/media';
41 37
 import {
42 38
     localParticipantRoleChanged,
43 39
     MAX_DISPLAY_NAME_LENGTH,
@@ -51,9 +47,7 @@ import {
51 47
     trackAdded,
52 48
     trackRemoved
53 49
 } from './react/features/base/tracks';
54
-import {
55
-    showDesktopPicker
56
-} from  './react/features/desktop-picker';
50
+import { showDesktopPicker } from  './react/features/desktop-picker';
57 51
 import {
58 52
     mediaPermissionPromptVisibilityChanged,
59 53
     suspendDetected

+ 1
- 1
react/features/base/media/actionTypes.js Voir le fichier

@@ -24,7 +24,7 @@ export const SET_CAMERA_FACING_MODE = Symbol('SET_CAMERA_FACING_MODE');
24 24
  *
25 25
  * {
26 26
  *     type: SET_VIDEO_AVAILABLE,
27
- *     muted: boolean
27
+ *     available: boolean
28 28
  * }
29 29
  */
30 30
 export const SET_VIDEO_AVAILABLE = Symbol('SET_VIDEO_AVAILABLE');

+ 12
- 12
react/features/base/media/actions.js Voir le fichier

@@ -17,9 +17,9 @@ import { CAMERA_FACING_MODE } from './constants';
17 17
  * @param {boolean} muted - True if the local audio is to be muted or false if
18 18
  * the local audio is to be unmuted.
19 19
  * @returns {{
20
- *      type: SET_AUDIO_MUTED,
21
- *      muted: boolean
22
- *  }}
20
+ *     type: SET_AUDIO_MUTED,
21
+ *     muted: boolean
22
+ * }}
23 23
  */
24 24
 export function setAudioMuted(muted: boolean) {
25 25
     return {
@@ -33,9 +33,9 @@ export function setAudioMuted(muted: boolean) {
33 33
  *
34 34
  * @param {CAMERA_FACING_MODE} cameraFacingMode - The camera facing mode to set.
35 35
  * @returns {{
36
- *      type: SET_CAMERA_FACING_MODE,
37
- *      cameraFacingMode: CAMERA_FACING_MODE
38
- *  }}
36
+ *     type: SET_CAMERA_FACING_MODE,
37
+ *     cameraFacingMode: CAMERA_FACING_MODE
38
+ * }}
39 39
  */
40 40
 export function setCameraFacingMode(cameraFacingMode: CAMERA_FACING_MODE) {
41 41
     return {
@@ -50,9 +50,9 @@ export function setCameraFacingMode(cameraFacingMode: CAMERA_FACING_MODE) {
50 50
  * @param {boolean} available - True if the local video is to be marked as
51 51
  * available or false if the local video is not available.
52 52
  * @returns {{
53
- *      type: SET_VIDEO_AVAILABLE,
54
- *      available: boolean
55
- *  }}
53
+ *     type: SET_VIDEO_AVAILABLE,
54
+ *     available: boolean
55
+ * }}
56 56
  */
57 57
 export function setVideoAvailable(available: boolean) {
58 58
     return {
@@ -67,9 +67,9 @@ export function setVideoAvailable(available: boolean) {
67 67
  * @param {boolean} muted - True if the local video is to be muted or false if
68 68
  * the local video is to be unmuted.
69 69
  * @returns {{
70
- *      type: SET_VIDEO_MUTED,
71
- *      muted: boolean
72
- *  }}
70
+ *     type: SET_VIDEO_MUTED,
71
+ *     muted: boolean
72
+ * }}
73 73
  */
74 74
 export function setVideoMuted(muted: boolean) {
75 75
     return {

+ 5
- 5
react/features/base/media/reducer.js Voir le fichier

@@ -5,8 +5,8 @@ import { ReducerRegistry } from '../redux';
5 5
 import {
6 6
     SET_AUDIO_MUTED,
7 7
     SET_CAMERA_FACING_MODE,
8
-    SET_VIDEO_MUTED,
9 8
     SET_VIDEO_AVAILABLE,
9
+    SET_VIDEO_MUTED,
10 10
     TOGGLE_CAMERA_FACING_MODE
11 11
 } from './actionTypes';
12 12
 import { CAMERA_FACING_MODE } from './constants';
@@ -79,16 +79,16 @@ const VIDEO_INITIAL_MEDIA_STATE = {
79 79
  */
80 80
 function _video(state = VIDEO_INITIAL_MEDIA_STATE, action) {
81 81
     switch (action.type) {
82
-    case SET_VIDEO_AVAILABLE:
82
+    case SET_CAMERA_FACING_MODE:
83 83
         return {
84 84
             ...state,
85
-            available: action.available
85
+            facingMode: action.cameraFacingMode
86 86
         };
87 87
 
88
-    case SET_CAMERA_FACING_MODE:
88
+    case SET_VIDEO_AVAILABLE:
89 89
         return {
90 90
             ...state,
91
-            facingMode: action.cameraFacingMode
91
+            available: action.available
92 92
         };
93 93
 
94 94
     case SET_VIDEO_MUTED:

+ 32
- 53
react/features/toolbox/middleware.js Voir le fichier

@@ -1,59 +1,16 @@
1 1
 /* @flow */
2 2
 
3
+import { SET_VIDEO_AVAILABLE, SET_VIDEO_MUTED } from '../base/media';
3 4
 import { MiddlewareRegistry } from '../base/redux';
4 5
 
5
-import {
6
-    CLEAR_TOOLBOX_TIMEOUT,
7
-    SET_TOOLBOX_TIMEOUT
8
-} from './actionTypes';
9
-
10
-import {
11
-    SET_VIDEO_AVAILABLE,
12
-    SET_VIDEO_MUTED
13
-} from '../../features/base/media/actionTypes';
14
-
15
-import {
16
-    setToolbarButton
17
-} from './actions';
18
-
19
-/**
20
- * Adjusts the state of toolbar's camera button.
21
- *
22
- * @param {Store} store - The Redux store instance.
23
- * @param {Object} action - Either SET_VIDEO_AVAILABLE or SET_VIDEO_MUTED.
24
- *
25
- * @returns {*}
26
- */
27
-function setCameraButton(store, action) {
28
-    const video = store.getState()['features/base/media'].video;
29
-    let available = video.available;
30
-
31
-    if (typeof action.available === 'boolean') {
32
-        available = action.available;
33
-    }
34
-
35
-    let muted = video.muted;
36
-
37
-    if (typeof action.muted === 'boolean') {
38
-        muted = action.muted;
39
-    }
40
-
41
-    const i18nKey = available ? 'videomute' : 'cameraDisabled';
42
-    const i18n = `[content]toolbar.${i18nKey}`;
43
-    const button = {
44
-        enabled: available,
45
-        i18n,
46
-        toggled: available ? muted : true
47
-    };
48
-
49
-    store.dispatch(setToolbarButton('camera', button));
50
-}
6
+import { setToolbarButton } from './actions';
7
+import { CLEAR_TOOLBOX_TIMEOUT, SET_TOOLBOX_TIMEOUT } from './actionTypes';
51 8
 
52 9
 /**
53 10
  * Middleware which intercepts Toolbox actions to handle changes to the
54 11
  * visibility timeout of the Toolbox.
55 12
  *
56
- * @param {Store} store - Redux store.
13
+ * @param {Store} store - The redux store.
57 14
  * @returns {Function}
58 15
  */
59 16
 MiddlewareRegistry.register(store => next => action => {
@@ -77,13 +34,35 @@ MiddlewareRegistry.register(store => next => action => {
77 34
     }
78 35
 
79 36
     case SET_VIDEO_AVAILABLE:
80
-    case SET_VIDEO_MUTED: {
81
-        setCameraButton(store, action);
82
-        break;
83
-    }
84
-
85
-
37
+    case SET_VIDEO_MUTED:
38
+        return _setVideoAvailableOrMuted(store, next, action);
86 39
     }
87 40
 
88 41
     return next(action);
89 42
 });
43
+
44
+/**
45
+ * Adjusts the state of toolbar's camera button.
46
+ *
47
+ * @param {Store} store - The redux store.
48
+ * @param {Function} next - The redux function to continue dispatching the
49
+ * specified {@code action} in the specified {@code store}.
50
+ * @param {Object} action - Either {@link SET_VIDEO_AVAILABLE} or
51
+ * {@link SET_VIDEO_MUTED}.
52
+ * @returns {Object} The new state that is the result of the reduction of the
53
+ * specified {@code action}.
54
+ */
55
+function _setVideoAvailableOrMuted({ dispatch, getState }, next, action) {
56
+    const result = next(action);
57
+
58
+    const { available, muted } = getState()['features/base/media'].video;
59
+    const i18nKey = available ? 'videomute' : 'cameraDisabled';
60
+
61
+    dispatch(setToolbarButton('camera', {
62
+        enabled: available,
63
+        i18n: `[content]toolbar.${i18nKey}`,
64
+        toggled: available ? muted : true
65
+    }));
66
+
67
+    return result;
68
+}

Chargement…
Annuler
Enregistrer