Lyubo Marinov пре 7 година
родитељ
комит
f9f194d6fe

+ 2
- 4
react/features/analytics/functions.js Прегледај датотеку

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

+ 4
- 5
react/features/base/lib-jitsi-meet/actions.js Прегледај датотеку

@@ -51,11 +51,10 @@ export function initLib() {
51 51
         dispatch({ type: LIB_WILL_INIT });
52 52
 
53 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 58
                 .then(() => dispatch({ type: LIB_DID_INIT }))
60 59
                 .catch(error => {
61 60
                     dispatch(libInitError(error));

+ 21
- 20
react/features/base/lib-jitsi-meet/functions.js Прегледај датотеку

@@ -1,6 +1,7 @@
1 1
 /* @flow */
2 2
 
3 3
 import { setConfigFromURLParams } from '../../base/config';
4
+import { toState } from '../../base/redux';
4 5
 import { loadScript } from '../../base/util';
5 6
 
6 7
 import JitsiMeetJS from './_';
@@ -31,6 +32,26 @@ export function createLocalTrack(type: string, deviceId: string) {
31 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 56
  * Determines whether a specific JitsiConnectionErrors instance indicates a
36 57
  * fatal JitsiConnection error.
@@ -102,23 +123,3 @@ export function loadConfig(url: string) {
102 123
 
103 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,8 +129,7 @@ export function toState(stateful: Function | Object) {
129 129
 
130 130
         const { getState } = stateful;
131 131
 
132
-        if (typeof getState === 'function'
133
-                && typeof stateful.dispatch === 'function') {
132
+        if (typeof getState === 'function') {
134 133
             return getState();
135 134
         }
136 135
     }

Loading…
Откажи
Сачувај