ソースを参照

rn: simplified code

There is no need for AbstractApp to require some getWindowLocation function.
It's only used in one place and we even polyfill it on mobile.

Thus replace it's usage with more specific functions.
j8
Saúl Ibarra Corretgé 6年前
コミット
e4c3e15791

+ 0
- 16
react/features/app/components/AbstractApp.js ファイルの表示

@@ -79,22 +79,6 @@ export class AbstractApp extends BaseApp<Props, *> {
79 79
         });
80 80
     }
81 81
 
82
-    /**
83
-     * Gets a {@code Location} object from the window with information about the
84
-     * current location of the document. Explicitly defined to allow extenders
85
-     * to override because React Native does not usually have a location
86
-     * property on its window unless debugging remotely in which case the
87
-     * browser that is the remote debugger will provide a location property on
88
-     * the window.
89
-     *
90
-     * @public
91
-     * @returns {Location} A {@code Location} object with information about the
92
-     * current location of the document.
93
-     */
94
-    getWindowLocation() {
95
-        return undefined;
96
-    }
97
-
98 82
     /**
99 83
      * Creates an extra {@link ReactElement}s to be added (unconditionaly)
100 84
      * alongside the main element.

+ 0
- 10
react/features/app/components/App.web.js ファイルの表示

@@ -17,16 +17,6 @@ import { AbstractApp } from './AbstractApp';
17 17
  * @extends AbstractApp
18 18
  */
19 19
 export class App extends AbstractApp {
20
-    /**
21
-     * Gets a Location object from the window with information about the current
22
-     * location of the document.
23
-     *
24
-     * @inheritdoc
25
-     */
26
-    getWindowLocation() {
27
-        return window.location;
28
-    }
29
-
30 20
     /**
31 21
      * Overrides the parent method to inject {@link AtlasKitThemeProvider} as
32 22
      * the top most component.

+ 0
- 32
react/features/app/functions.any.js ファイルの表示

@@ -1,32 +0,0 @@
1
-// @flow
2
-
3
-import { getAppProp } from '../base/app';
4
-import { toState } from '../base/redux';
5
-import { getServerURL } from '../base/settings';
6
-
7
-/**
8
- * Retrieves the default URL for the app. This can either come from a prop to
9
- * the root App component or be configured in the settings.
10
- *
11
- * @param {Function|Object} stateful - The redux store or {@code getState}
12
- * function.
13
- * @returns {string} - Default URL for the app.
14
- */
15
-export function getDefaultURL(stateful: Function | Object) {
16
-    const state = toState(stateful);
17
-    const { app } = state['features/base/app'];
18
-
19
-    // If the execution environment provides a Location abstraction (e.g. a Web
20
-    // browser), then we'll presume it's the one and only base URL it can be on.
21
-    const windowLocation = app.getWindowLocation();
22
-
23
-    if (windowLocation) {
24
-        const href = windowLocation.toString();
25
-
26
-        if (href) {
27
-            return href;
28
-        }
29
-    }
30
-
31
-    return getAppProp(state, 'defaultURL') || getServerURL(state);
32
-}

+ 17
- 1
react/features/app/functions.native.js ファイルの表示

@@ -2,7 +2,23 @@
2 2
 
3 3
 import { NativeModules } from 'react-native';
4 4
 
5
-export * from './functions.any';
5
+import { getAppProp } from '../base/app';
6
+import { toState } from '../base/redux';
7
+import { getServerURL } from '../base/settings';
8
+
9
+/**
10
+ * Retrieves the default URL for the app. This can either come from a prop to
11
+ * the root App component or be configured in the settings.
12
+ *
13
+ * @param {Function|Object} stateful - The redux store or {@code getState}
14
+ * function.
15
+ * @returns {string} - Default URL for the app.
16
+ */
17
+export function getDefaultURL(stateful: Function | Object) {
18
+    const state = toState(stateful);
19
+
20
+    return getAppProp(state, 'defaultURL') || getServerURL(state);
21
+}
6 22
 
7 23
 /**
8 24
  * Returns application name.

+ 21
- 1
react/features/app/functions.web.js ファイルの表示

@@ -1,9 +1,29 @@
1 1
 // @flow
2 2
 
3
-export * from './functions.any';
3
+import { toState } from '../base/redux';
4
+import { getServerURL } from '../base/settings';
4 5
 
5 6
 declare var interfaceConfig: Object;
6 7
 
8
+/**
9
+ * Retrieves the default URL for the app. This can either come from a prop to
10
+ * the root App component or be configured in the settings.
11
+ *
12
+ * @param {Function|Object} stateful - The redux store or {@code getState}
13
+ * function.
14
+ * @returns {string} - Default URL for the app.
15
+ */
16
+export function getDefaultURL(stateful: Function | Object) {
17
+    const state = toState(stateful);
18
+    const { href } = window.location;
19
+
20
+    if (href) {
21
+        return href;
22
+    }
23
+
24
+    return getServerURL(state);
25
+}
26
+
7 27
 /**
8 28
  * Returns application name.
9 29
  *

読み込み中…
キャンセル
保存