diff --git a/src/create/CreateLinkView.js b/src/create/CreateLinkView.js index 0dd5bc6..784cb66 100644 --- a/src/create/CreateLinkView.js +++ b/src/create/CreateLinkView.js @@ -22,17 +22,8 @@ export class CreateLinkView extends TemplateView { render(t, vm) { const link = t.a({href: vm => vm.linkUrl}, vm => vm.linkUrl); return t.div({className: "CreateLinkView card"}, [ - t.h1( - {className: {hidden: vm => vm.previewViewModel}}, - "Create shareable links to Matrix rooms, users or messages without being tied to any app" - ), - t.mapView(vm => vm.previewViewModel, childVM => childVM ? new PreviewView(childVM) : null), - t.div({className: {hidden: vm => !vm.linkUrl}}, [ - t.h2(link), - t.div(copyButton(t, () => vm.linkUrl, "Copy link", "fullwidth primary")), - t.div(t.button({className: "secondary fullwidth", onClick: () => this._clear()}, "Or create another link")), - ]), - t.form({action: "#", onSubmit: evt => this._onSubmit(evt), className: {hidden: vm => vm.linkUrl}}, [ + t.h1("Create shareable links to Matrix rooms, users or messages without being tied to any app"), + t.form({action: "#", onSubmit: evt => this._onSubmit(evt)}, [ t.div(t.input({ className: "fullwidth large", type: "text", @@ -52,7 +43,6 @@ export class CreateLinkView extends TemplateView { const {identifier} = form.elements; this.value.createLink(identifier.value); identifier.value = ""; - } _onIdentifierChange(evt) { @@ -63,10 +53,4 @@ export class CreateLinkView extends TemplateView { inputField.setCustomValidity(""); } } - - _clear() { - this.value.clear(); - const textField = this.root().querySelector("input[name=identifier]"); - textField.focus(); - } } diff --git a/src/create/CreateLinkViewModel.js b/src/create/CreateLinkViewModel.js index 6e5fcc5..21f4c81 100644 --- a/src/create/CreateLinkViewModel.js +++ b/src/create/CreateLinkViewModel.js @@ -32,28 +32,7 @@ export class CreateLinkViewModel extends ViewModel { async createLink(identifier) { this._link = Link.parse(identifier); if (this._link) { - // TODO: abort previous load - this.previewViewModel = new PreviewViewModel(this.childOptions({ - link: this._link, - consentedServers: this._link.servers, - })); - this.emitChange(); - await this.previewViewModel.load(); - } else { - this.previewViewModel = null; + this.openLink("#" + this._link.toFragment()); } - this.emitChange(); - } - - get linkUrl() { - if (this._link) { - return `${this.origin}/#${this._link.toFragment()}`; - } - } - - clear() { - this._link = null; - this.previewViewModel = null; - this.emitChange(); } }