fix(deep-linking): Don't rely on custom scheme
This commit is contained in:
parent
e0fdeea69b
commit
840c0190c4
|
@ -50,7 +50,6 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
|
|||
super(props);
|
||||
|
||||
// Bind event handlers so they are only bound once per instance.
|
||||
this._openDesktopApp = this._openDesktopApp.bind(this);
|
||||
this._onLaunchWeb = this._onLaunchWeb.bind(this);
|
||||
this._onTryAgain = this._onTryAgain.bind(this);
|
||||
}
|
||||
|
@ -61,7 +60,6 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
|
|||
* @inheritdoc
|
||||
*/
|
||||
componentDidMount() {
|
||||
this._openDesktopApp();
|
||||
sendAnalytics(
|
||||
createDeepLinkingPageEvent(
|
||||
'displayed', 'DeepLinkingDesktop', { isMobileBrowser: false }));
|
||||
|
@ -133,17 +131,6 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
|
|||
);
|
||||
}
|
||||
|
||||
_openDesktopApp: () => {}
|
||||
|
||||
/**
|
||||
* Dispatches the <tt>openDesktopApp</tt> action.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
_openDesktopApp() {
|
||||
this.props.dispatch(openDesktopApp());
|
||||
}
|
||||
|
||||
_onTryAgain: () => {}
|
||||
|
||||
/**
|
||||
|
@ -155,7 +142,7 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
|
|||
sendAnalytics(
|
||||
createDeepLinkingPageEvent(
|
||||
'clicked', 'tryAgainButton', { isMobileBrowser: false }));
|
||||
this._openDesktopApp();
|
||||
this.props.dispatch(openDesktopApp());
|
||||
}
|
||||
|
||||
_onLaunchWeb: () => {}
|
||||
|
|
|
@ -8,28 +8,7 @@ import {
|
|||
DeepLinkingMobilePage,
|
||||
NoMobileApp
|
||||
} from './components';
|
||||
import { _shouldShowDeepLinkingDesktopPage }
|
||||
from './shouldShowDeepLinkingDesktopPage';
|
||||
|
||||
/**
|
||||
* Promise that resolves when the window load event is received.
|
||||
*
|
||||
* @type {Promise<void>}
|
||||
*/
|
||||
const windowLoadedPromise = new Promise(resolve => {
|
||||
/**
|
||||
* Handler for the window load event.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function onWindowLoad() {
|
||||
resolve();
|
||||
window.removeEventListener('load', onWindowLoad);
|
||||
}
|
||||
|
||||
window.addEventListener('load', onWindowLoad);
|
||||
});
|
||||
|
||||
import { _openDesktopApp } from './openDesktopApp';
|
||||
|
||||
/**
|
||||
* Generates a deep linking URL based on the current window URL.
|
||||
|
@ -96,23 +75,17 @@ export function getDeepLinkingPage(state) {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return _shouldShowDeepLinkingDesktopPage().then(
|
||||
return _openDesktopApp().then(
|
||||
// eslint-disable-next-line no-confusing-arrow
|
||||
show => show ? DeepLinkingDesktopPage : undefined);
|
||||
result => result ? DeepLinkingDesktopPage : undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the desktop app.
|
||||
*
|
||||
* @returns {void}
|
||||
* @returns {Promise<boolean>} - Resolves with true if the attempt to open the desktop app was successful and resolves
|
||||
* with false otherwise.
|
||||
*/
|
||||
export function openDesktopApp() {
|
||||
windowLoadedPromise.then(() => {
|
||||
// If the code for opening the deep link is executed before the window
|
||||
// load event, something with the internal chrome state goes wrong. The
|
||||
// result is that no window load event is received which is the cause
|
||||
// for some permission prompts to not be displayed. In our case the GUM
|
||||
// prompt wasn't displayed which causes the GUM call to never finish.
|
||||
window.location.href = generateDeepLinkingURL();
|
||||
});
|
||||
return _openDesktopApp();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Opens the desktop app.
|
||||
*
|
||||
* @returns {Promise<boolean>} - Resolves with true if the attempt to open the desktop app was successful and resolves
|
||||
* with false otherwise.
|
||||
*/
|
||||
export function _openDesktopApp() {
|
||||
return Promise.resolve(false);
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
/**
|
||||
* Resolves with <tt>true</tt> if the deep linking page should be shown and with
|
||||
* <tt>false</tt> otherwise.
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
export function _shouldShowDeepLinkingDesktopPage() {
|
||||
return Promise.resolve(false);
|
||||
}
|
Loading…
Reference in New Issue