[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.
This commit is contained in:
parent
207393d98e
commit
6003b560ae
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
#import <CoreText/CoreText.h>
|
||||
#include <mach/mach_time.h>
|
||||
|
||||
#import <React/RCTAssert.h>
|
||||
#import <React/RCTLinkingManager.h>
|
||||
|
@ -239,6 +240,17 @@ static NSMapTable<NSString *, JitsiMeetView *> *views;
|
|||
props[@"url"] = urlObject;
|
||||
}
|
||||
|
||||
// XXX The method loadURLObject: is supposed to be imperative i.e. a second
|
||||
// invocation with one and the same URL is expected to join the respective
|
||||
// conference again if the first invocation was followed by leaving the
|
||||
// conference. However, React and, respectively,
|
||||
// appProperties/initialProperties are declarative expressions i.e. one and
|
||||
// the same URL will not trigger componentWillReceiveProps in the JavaScript
|
||||
// source code. The workaround implemented bellow introduces imperativeness
|
||||
// in React Component props by defining a unique value per loadURLObject:
|
||||
// invocation.
|
||||
props[@"timestamp"] = @(mach_absolute_time());
|
||||
|
||||
if (rootView) {
|
||||
// Update props with the new URL.
|
||||
rootView.appProperties = props;
|
||||
|
|
|
@ -47,6 +47,10 @@ export class AbstractApp extends Component {
|
|||
*/
|
||||
store: PropTypes.object,
|
||||
|
||||
// XXX Refer to the implementation of loadURLObject: in
|
||||
// ios/sdk/src/JitsiMeetView.m for further information.
|
||||
timestamp: PropTypes.any,
|
||||
|
||||
/**
|
||||
* The URL, if any, with which the app was launched.
|
||||
*/
|
||||
|
@ -143,7 +147,11 @@ export class AbstractApp extends Component {
|
|||
let { url } = nextProps;
|
||||
|
||||
url = toURLString(url);
|
||||
if (toURLString(this.props.url) !== url) {
|
||||
if (toURLString(this.props.url) !== url
|
||||
|
||||
// XXX Refer to the implementation of loadURLObject: in
|
||||
// ios/sdk/src/JitsiMeetView.m for further information.
|
||||
|| this.props.timestamp !== nextProps.timestamp) {
|
||||
this._openURL(url || this._getDefaultURL());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue