Sfoglia il codice sorgente

rn: drop deep / universal links handling from JS

It's now all handled in the SDK an we'll get the new URLs via props.
master
Saúl Ibarra Corretgé 6 anni fa
parent
commit
3fa5aed950
2 ha cambiato i file con 6 aggiunte e 149 eliminazioni
  1. 2
    39
      react/features/app/components/App.native.js
  2. 4
    110
      react/index.native.js

+ 2
- 39
react/features/app/components/App.native.js Vedi File

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3 3
 import React from 'react';
4
-import { Linking } from 'react-native';
5 4
 
6 5
 import '../../analytics';
7 6
 import '../../authentication';
@@ -73,9 +72,6 @@ export class App extends AbstractApp {
73 72
     constructor(props: Props) {
74 73
         super(props);
75 74
 
76
-        // Bind event handlers so they are only bound once for every instance.
77
-        this._onLinkingURL = this._onLinkingURL.bind(this);
78
-
79 75
         // In the Release configuration, React Native will (intentionally) throw
80 76
         // an unhandled JavascriptException for an unhandled JavaScript error.
81 77
         // This will effectively kill the app. In accord with the Web, do not
@@ -84,12 +80,11 @@ export class App extends AbstractApp {
84 80
     }
85 81
 
86 82
     /**
87
-     * Subscribe to notifications about activating URLs registered to be handled
88
-     * by this app.
83
+     * Initializes the color scheme.
89 84
      *
90 85
      * @inheritdoc
86
+     *
91 87
      * @returns {void}
92
-     * @see https://facebook.github.io/react-native/docs/linking.html
93 88
      */
94 89
     componentDidMount() {
95 90
         super.componentDidMount();
@@ -99,22 +94,6 @@ export class App extends AbstractApp {
99 94
             // unnecessary re-renders.
100 95
             this.state.store.dispatch(setColorScheme(this.props.colorScheme));
101 96
         });
102
-
103
-        Linking.addEventListener('url', this._onLinkingURL);
104
-    }
105
-
106
-    /**
107
-     * Unsubscribe from notifications about activating URLs registered to be
108
-     * handled by this app.
109
-     *
110
-     * @inheritdoc
111
-     * @returns {void}
112
-     * @see https://facebook.github.io/react-native/docs/linking.html
113
-     */
114
-    componentWillUnmount() {
115
-        Linking.removeEventListener('url', this._onLinkingURL);
116
-
117
-        super.componentWillUnmount();
118 97
     }
119 98
 
120 99
     /**
@@ -170,22 +149,6 @@ export class App extends AbstractApp {
170 149
         }
171 150
     }
172 151
 
173
-    _onLinkingURL: (*) => void;
174
-
175
-    /**
176
-     * Notified by React's Linking API that a specific URL registered to be
177
-     * handled by this app was activated.
178
-     *
179
-     * @param {Object} event - The details of the notification/event.
180
-     * @param {string} event.url - The URL registered to be handled by this app
181
-     * which was activated.
182
-     * @private
183
-     * @returns {void}
184
-     */
185
-    _onLinkingURL({ url }) {
186
-        super._openURL(url);
187
-    }
188
-
189 152
     /**
190 153
      * Renders the platform specific dialog container.
191 154
      *

+ 4
- 110
react/index.native.js Vedi File

@@ -10,15 +10,12 @@
10 10
 // collect the polyfills' files.
11 11
 import './features/base/lib-jitsi-meet/native/polyfills-bundler';
12 12
 
13
-import React, { Component } from 'react';
14
-import { AppRegistry, Linking, NativeModules } from 'react-native';
13
+import React, { PureComponent } from 'react';
14
+import { AppRegistry } from 'react-native';
15 15
 
16 16
 import { App } from './features/app';
17
-import { equals } from './features/base/redux';
18 17
 import { IncomingCallApp } from './features/mobile/incoming-call';
19 18
 
20
-const logger = require('jitsi-meet-logger').getLogger(__filename);
21
-
22 19
 /**
23 20
  * The type of the React {@code Component} props of {@link Root}.
24 21
  */
@@ -30,17 +27,6 @@ type Props = {
30 27
     url: Object | string
31 28
 };
32 29
 
33
-/**
34
- * The type of the React {@code Component} state of {@link Root}.
35
- */
36
-type State = {
37
-
38
-    /**
39
-     * The URL, if any, with which the app was launched.
40
-     */
41
-    url: ?Object | string
42
-};
43
-
44 30
 /**
45 31
  * React Native doesn't support specifying props to the main/root component (in
46 32
  * the JS/JSX source code). So create a wrapper React Component (class) around
@@ -48,82 +34,7 @@ type State = {
48 34
  *
49 35
  * @extends Component
50 36
  */
51
-class Root extends Component<Props, State> {
52
-    /**
53
-     * Initializes a new {@code Root} instance.
54
-     *
55
-     * @param {Props} props - The read-only properties with which the new
56
-     * instance is to be initialized.
57
-     */
58
-    constructor(props) {
59
-        super(props);
60
-
61
-        this.state = {
62
-            url: this.props.url
63
-        };
64
-
65
-        // Handle the URL, if any, with which the app was launched. But props
66
-        // have precedence.
67
-        if (typeof this.props.url === 'undefined') {
68
-            this._getInitialURL()
69
-                .then(url => {
70
-                    if (typeof this.state.url === 'undefined') {
71
-                        this.setState({ url });
72
-                    }
73
-                })
74
-                .catch(err => {
75
-                    logger.error('Failed to get initial URL', err);
76
-
77
-                    if (typeof this.state.url === 'undefined') {
78
-                        // Start with an empty URL if getting the initial URL
79
-                        // fails; otherwise, nothing will be rendered.
80
-                        this.setState({ url: null });
81
-                    }
82
-                });
83
-        }
84
-    }
85
-
86
-    /**
87
-     * Gets the initial URL the app was launched with. This can be a universal
88
-     * (or deep) link, or a CallKit intent in iOS. Since the native
89
-     * {@code Linking} module doesn't provide a way to access intents in iOS,
90
-     * those are handled with the {@code LaunchOptions} module, which
91
-     * essentially provides a replacement which takes that into consideration.
92
-     *
93
-     * @private
94
-     * @returns {Promise} - A promise which will be fulfilled with the URL that
95
-     * the app was launched with.
96
-     */
97
-    _getInitialURL() {
98
-        if (NativeModules.LaunchOptions) {
99
-            return NativeModules.LaunchOptions.getInitialURL();
100
-        }
101
-
102
-        return Linking.getInitialURL();
103
-    }
104
-
105
-    /**
106
-     * Implements React's {@link Component#componentDidUpdate()}.
107
-     *
108
-     * New props can be set from the native side by setting the appProperties
109
-     * property (on iOS) or calling setAppProperties (on Android).
110
-     *
111
-     * @inheritdoc
112
-     */
113
-    componentDidUpdate(prevProps, prevState) {
114
-        // Ignore the special state update triggered on {@code Root}
115
-        // instantiation where an undefined url prop is set to a default.
116
-        if (typeof prevState.url === 'undefined'
117
-                && typeof this.state.url !== 'undefined') {
118
-            return;
119
-        }
120
-
121
-        if (!equals(prevProps.url, this.props.url)) {
122
-            // eslint-disable-next-line  react/no-did-update-set-state
123
-            this.setState({ url: this.props.url || null });
124
-        }
125
-    }
126
-
37
+class Root extends PureComponent<Props> {
127 38
     /**
128 39
      * Implements React's {@link Component#render()}.
129 40
      *
@@ -131,26 +42,9 @@ class Root extends Component<Props, State> {
131 42
      * @returns {ReactElement}
132 43
      */
133 44
     render() {
134
-        const { url } = this.state;
135
-
136
-        // XXX We don't render the App component until we get the initial URL.
137
-        // Either it's null or some other non-null defined value.
138
-        if (typeof url === 'undefined') {
139
-            return null;
140
-        }
141
-
142
-        const {
143
-            // The following props are forked in state:
144
-            url: _, // eslint-disable-line no-unused-vars
145
-
146
-            // The remaining props are passed through to App.
147
-            ...props
148
-        } = this.props;
149
-
150 45
         return (
151 46
             <App
152
-                { ...props }
153
-                url = { url } />
47
+                { ...this.props } />
154 48
         );
155 49
     }
156 50
 }

Loading…
Annulla
Salva