From c26b8dcec12c0a8c65ff646384bf81374471a7c8 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 24 Aug 2021 13:12:40 -0700 Subject: [PATCH] Display a little message while trying to redirect --- css/open.css | 20 ++++++++++++++++++++ src/open/OpenLinkView.js | 20 +++++++++++++++++--- src/open/OpenLinkViewModel.js | 2 +- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/css/open.css b/css/open.css index 560f7a3..25f3930 100644 --- a/css/open.css +++ b/css/open.css @@ -50,3 +50,23 @@ limitations under the License. border-bottom: 1px solid var(--grey); padding: 4px 0; } + +.OpeningClientView { + display: flex; + align-items: center; + flex-direction: column; + margin: 0; +} + +.OpeningClientView .defaultAvatar { + width: 64px; + height: 64px; + background-image: url('../images/chat-icon.svg'); + background-repeat: no-repeat; + background-position: center; + background-size: 85%; +} + +.OpeningClientView .spinner { + margin-top: 15px; +} diff --git a/src/open/OpenLinkView.js b/src/open/OpenLinkView.js index c7dfe0f..d545885 100644 --- a/src/open/OpenLinkView.js +++ b/src/open/OpenLinkView.js @@ -22,14 +22,28 @@ import {ServerConsentView} from "./ServerConsentView.js"; export class OpenLinkView extends TemplateView { render(t, vm) { return t.div({className: "OpenLinkView card"}, [ - t.mapView(vm => vm.previewViewModel, previewVM => previewVM ? - new ShowLinkView(vm) : - new ServerConsentView(vm.serverConsentViewModel) + t.map(vm => vm.tryingLink, tryingLink => tryingLink ? + t.view(new TryingLinkView(vm)) : + t.mapView(vm => vm.previewViewModel, previewVM => previewVM ? + new ShowLinkView(vm) : + new ServerConsentView(vm.serverConsentViewModel) + ), ), ]); } } +class TryingLinkView extends TemplateView { + render (t, vm) { + return t.div({ className: "OpeningClientView" }, [ + t.div({className: "defaultAvatar"}), + t.h1("Trying to open your default client..."), + t.span("If this doesn't work, you will be redirected shortly."), + t.div({className: "spinner"}), + ]); + } +} + class ShowLinkView extends TemplateView { render(t, vm) { return t.div([ diff --git a/src/open/OpenLinkViewModel.js b/src/open/OpenLinkViewModel.js index 2580d38..ee5d17c 100644 --- a/src/open/OpenLinkViewModel.js +++ b/src/open/OpenLinkViewModel.js @@ -48,7 +48,7 @@ export class OpenLinkViewModel extends ViewModel { setTimeout(() => { this.tryingLink = false; this.emitChange(); - }, 5000); + }, 1000); this.openLink(matrixUrl); } }