From f02dc5aae972044f05f14298cec483208e38cdbd Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 12 Apr 2021 15:15:21 +0200 Subject: [PATCH] also show install options for https deeplinks for native app --- src/open/ClientView.js | 8 ++------ src/open/ClientViewModel.js | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/open/ClientView.js b/src/open/ClientView.js index 408ba87..8924054 100644 --- a/src/open/ClientView.js +++ b/src/open/ClientView.js @@ -53,12 +53,8 @@ export class ClientView extends TemplateView { ]), t.img({className: "clientIcon", src: vm.iconUrl}) ]), - t.mapView(vm => vm.stage, stage => { - switch (stage) { - case "open": return new OpenClientView(vm); - case "install": return new InstallClientView(vm); - } - }), + t.ifView(vm => vm.showOpen, vm => new OpenClientView(vm)), + t.ifView(vm => vm.showInstall, vm => new InstallClientView(vm)) ]); } } diff --git a/src/open/ClientViewModel.js b/src/open/ClientViewModel.js index cf47c23..2c54232 100644 --- a/src/open/ClientViewModel.js +++ b/src/open/ClientViewModel.js @@ -49,6 +49,15 @@ export class ClientViewModel extends ViewModel { this.installActions = this._createInstallActions(); this._clientCanIntercept = !!(this._nativePlatform && this._client.canInterceptMatrixToLinks(this._nativePlatform)); this._showOpen = this.openActions.length && !this._clientCanIntercept; + const proposedDeepLink = this._client.getDeepLink(this._proposedPlatform, this._link); + this._openWillNavigateIfNotInstalled = false; + if (this._showOpen && !isWebPlatform(this._proposedPlatform)) { + try { + if (new URL(proposedDeepLink).protocol === "https:") { + this._openWillNavigateIfNotInstalled = true; + } + } catch (err) {} + } } // these are only shown in the open stage @@ -170,9 +179,17 @@ export class ClientViewModel extends ViewModel { return this._client.icon; } - get stage() { - return this._showOpen ? "open" : "install"; - } + get showOpen() { + return this._showOpen; + } + + get showInstall() { + // also show install options in open screen if the deeplink is + // a https link that should be intercepted by the native app + // because if it isn't installed, you will just go to that + // website and never see the install options here. + return !this._showOpen || this._openWillNavigateIfNotInstalled; + } get textInstructions() { let instructions = this._client.getLinkInstructions(this._proposedPlatform, this._link);