Ver código fonte

[RN] Fix opening the same URL multiple times

Deep/universal linking now utilizes loadURL (when possible). But loadURL
is imperative in the native source code while its JavaScript counterpart
i.e. React App Component prop url is declarative. So there's the
following bug: open a URL, leave the conference (by tapping the hangup
button, for example), and then opening the same URL actually leaves you
on the Welcome page (if enabled; otherwise, a black screen).

The implementation has a flow though: opening the same URL twice in a
row without an intervening leave will leave the first opening and join
the new opening. Which can be improved by not leaving and joining if the
conference is joined, joining, an not leaving. But that can be done
separately as an improvement independent of the current implementation
details.
master
Lyubo Marinov 7 anos atrás
pai
commit
6003b560ae

+ 12
- 0
ios/sdk/src/JitsiMeetView.m Ver arquivo

@@ -15,6 +15,7 @@
15 15
  */
16 16
 
17 17
 #import <CoreText/CoreText.h>
18
+#include <mach/mach_time.h>
18 19
 
19 20
 #import <React/RCTAssert.h>
20 21
 #import <React/RCTLinkingManager.h>
@@ -239,6 +240,17 @@ static NSMapTable<NSString *, JitsiMeetView *> *views;
239 240
         props[@"url"] = urlObject;
240 241
     }
241 242
 
243
+    // XXX The method loadURLObject: is supposed to be imperative i.e. a second
244
+    // invocation with one and the same URL is expected to join the respective
245
+    // conference again if the first invocation was followed by leaving the
246
+    // conference. However, React and, respectively,
247
+    // appProperties/initialProperties are declarative expressions i.e. one and
248
+    // the same URL will not trigger componentWillReceiveProps in the JavaScript
249
+    // source code. The workaround implemented bellow introduces imperativeness
250
+    // in React Component props by defining a unique value per loadURLObject:
251
+    // invocation.
252
+    props[@"timestamp"] = @(mach_absolute_time());
253
+
242 254
     if (rootView) {
243 255
         // Update props with the new URL.
244 256
         rootView.appProperties = props;

+ 9
- 1
react/features/app/components/AbstractApp.js Ver arquivo

@@ -47,6 +47,10 @@ export class AbstractApp extends Component {
47 47
          */
48 48
         store: PropTypes.object,
49 49
 
50
+        // XXX Refer to the implementation of loadURLObject: in
51
+        // ios/sdk/src/JitsiMeetView.m for further information.
52
+        timestamp: PropTypes.any,
53
+
50 54
         /**
51 55
          * The URL, if any, with which the app was launched.
52 56
          */
@@ -143,7 +147,11 @@ export class AbstractApp extends Component {
143 147
         let { url } = nextProps;
144 148
 
145 149
         url = toURLString(url);
146
-        if (toURLString(this.props.url) !== url) {
150
+        if (toURLString(this.props.url) !== url
151
+
152
+                // XXX Refer to the implementation of loadURLObject: in
153
+                // ios/sdk/src/JitsiMeetView.m for further information.
154
+                || this.props.timestamp !== nextProps.timestamp) {
147 155
             this._openURL(url || this._getDefaultURL());
148 156
         }
149 157
     }

Carregando…
Cancelar
Salvar