瀏覽代碼

Coding style

master
Lyubo Marinov 8 年之前
父節點
當前提交
f9f194d6fe

+ 2
- 4
react/features/analytics/functions.js 查看文件

15
  */
15
  */
16
 export function initAnalytics({ getState }) {
16
 export function initAnalytics({ getState }) {
17
     getJitsiMeetGlobalNS().analyticsHandlers = [];
17
     getJitsiMeetGlobalNS().analyticsHandlers = [];
18
-
19
-    // legacy support for old analytics location
20
-    window.analyticsHandlers = [];
18
+    window.analyticsHandlers = []; // Legacy support.
21
 
19
 
22
     const { analytics } = JitsiMeetJS;
20
     const { analytics } = JitsiMeetJS;
23
 
21
 
24
-    if (!isAnalyticsEnabled({ getState }) || !analytics) {
22
+    if (!analytics || !isAnalyticsEnabled(getState)) {
25
         return;
23
         return;
26
     }
24
     }
27
 
25
 

+ 4
- 5
react/features/base/lib-jitsi-meet/actions.js 查看文件

51
         dispatch({ type: LIB_WILL_INIT });
51
         dispatch({ type: LIB_WILL_INIT });
52
 
52
 
53
         return (
53
         return (
54
-            JitsiMeetJS.init(
55
-                    Object.assign({
56
-                        enableAnalyticsLogging: isAnalyticsEnabled({ getState })
57
-                    },
58
-                    config))
54
+            JitsiMeetJS.init({
55
+                enableAnalyticsLogging: isAnalyticsEnabled(getState),
56
+                ...config
57
+            })
59
                 .then(() => dispatch({ type: LIB_DID_INIT }))
58
                 .then(() => dispatch({ type: LIB_DID_INIT }))
60
                 .catch(error => {
59
                 .catch(error => {
61
                     dispatch(libInitError(error));
60
                     dispatch(libInitError(error));

+ 21
- 20
react/features/base/lib-jitsi-meet/functions.js 查看文件

1
 /* @flow */
1
 /* @flow */
2
 
2
 
3
 import { setConfigFromURLParams } from '../../base/config';
3
 import { setConfigFromURLParams } from '../../base/config';
4
+import { toState } from '../../base/redux';
4
 import { loadScript } from '../../base/util';
5
 import { loadScript } from '../../base/util';
5
 
6
 
6
 import JitsiMeetJS from './_';
7
 import JitsiMeetJS from './_';
31
             .then(([ jitsiLocalTrack ]) => jitsiLocalTrack));
32
             .then(([ jitsiLocalTrack ]) => jitsiLocalTrack));
32
 }
33
 }
33
 
34
 
35
+/**
36
+ * Determines whether analytics is enabled in a specific redux {@code store}.
37
+ *
38
+ * @param {Function|Object} stateful - The redux store, state, or
39
+ * {@code getState} function.
40
+ * @returns {boolean} If analytics is enabled, {@code true}; {@code false},
41
+ * otherwise.
42
+ */
43
+export function isAnalyticsEnabled(stateful: Function | Object) {
44
+    const {
45
+        analyticsScriptUrls,
46
+        disableThirdPartyRequests
47
+    } = toState(stateful)['features/base/config'];
48
+
49
+    return (
50
+        !disableThirdPartyRequests
51
+            && Array.isArray(analyticsScriptUrls)
52
+            && Boolean(analyticsScriptUrls.length));
53
+}
54
+
34
 /**
55
 /**
35
  * Determines whether a specific JitsiConnectionErrors instance indicates a
56
  * Determines whether a specific JitsiConnectionErrors instance indicates a
36
  * fatal JitsiConnection error.
57
  * fatal JitsiConnection error.
102
 
123
 
103
     return promise;
124
     return promise;
104
 }
125
 }
105
-
106
-/**
107
- * Evaluates whether analytics is enabled or not based on
108
- * the redux {@code store}.
109
- *
110
- * @param {Store} store - The redux store in which the specified {@code action}
111
- * is being dispatched.
112
- * @returns {boolean} True if analytics is enabled, false otherwise.
113
- */
114
-export function isAnalyticsEnabled({ getState }: { getState: Function }) {
115
-    const {
116
-        analyticsScriptUrls,
117
-        disableThirdPartyRequests
118
-    } = getState()['features/base/config'];
119
-
120
-    const scriptURLs = Array.isArray(analyticsScriptUrls)
121
-        ? analyticsScriptUrls : [];
122
-
123
-    return Boolean(scriptURLs.length) && !disableThirdPartyRequests;
124
-}

+ 1
- 2
react/features/base/redux/functions.js 查看文件

129
 
129
 
130
         const { getState } = stateful;
130
         const { getState } = stateful;
131
 
131
 
132
-        if (typeof getState === 'function'
133
-                && typeof stateful.dispatch === 'function') {
132
+        if (typeof getState === 'function') {
134
             return getState();
133
             return getState();
135
         }
134
         }
136
     }
135
     }

Loading…
取消
儲存