Avoid using empty list to represent 'no element'

This commit is contained in:
Danila Fedorin 2021-09-16 21:44:07 -07:00
parent 86196d4c83
commit 9a0d21df78

View file

@ -38,33 +38,37 @@ export class OpenLinkView extends TemplateView {
class TryingLinkView extends TemplateView { class TryingLinkView extends TemplateView {
render (t, vm) { render (t, vm) {
const explanation = vm.name ? t.span(["Select ", t.strong(`"Open ${vm.name}"`), " to launch the app."]) : []; const children = [
const redirectNotice = vm.autoRedirect ? "If this doesn't work, you will be redirected shortly." : []; vm.iconUrl ? t.img({ className: "clientIcon", src: vm.iconUrl }) : t.div({className: "defaultAvatar"}),
const webLink = vm.webDeepLink ? t.h1(vm.name ? `Opening ${vm.name}` : "Trying to open your default client..."),
t.span(["You can also ", t.a({ ]
if (vm.name) {
children.push(t.span(["Select ", t.strong(`"Open ${vm.name}"`), " to launch the app."]));
}
if (vm.autoRedirect) {
children.push("If this doesn't work, you will be redirected shortly.");
}
if (vm.webDeepLink) {
children.push(t.span(["You can also ", t.a({
href: vm.webDeepLink, href: vm.webDeepLink,
target: "_blank", target: "_blank",
rel: "noopener noreferrer", rel: "noopener noreferrer",
}, `open ${vm.name} in your browser.`)]) : }, `open ${vm.name} in your browser.`)]));
[]; }
const timeoutOptions = t.span({ className: "timeoutOptions" }, [ const timeoutOptions = t.span({ className: "timeoutOptions" }, [
t.strong("Not working? "), t.strong("Not working? "),
t.a({ href: vm.deepLink, onClick: () => vm.startSpinner() }, "Try again"), t.a({ href: vm.deepLink, onClick: () => vm.startSpinner() }, "Try again"),
" or ", " or ",
t.button({ className: "text", onClick: () => vm.close() }, "select another app.") t.button({ className: "text", onClick: () => vm.close() }, "select another app.")
]); ]);
children.push(
return t.div({ className: "OpeningClientView" }, [
vm.iconUrl ? t.img({ className: "clientIcon", src: vm.iconUrl }) : t.div({className: "defaultAvatar"}),
t.h1(vm.name ? `Opening ${vm.name}` : "Trying to open your default client..."),
explanation,
redirectNotice,
webLink,
t.map(vm => vm.trying, trying => trying ? t.map(vm => vm.trying, trying => trying ?
t.div({className: "spinner"}) : t.div({className: "spinner"}) :
timeoutOptions timeoutOptions
), ),
]); );
return t.div({ className: "OpeningClientView" }, children);
} }
} }