load link when creating rather than previewing it
This commit is contained in:
parent
e13c943d3f
commit
09c3f09d8b
@ -22,17 +22,8 @@ export class CreateLinkView extends TemplateView {
|
|||||||
render(t, vm) {
|
render(t, vm) {
|
||||||
const link = t.a({href: vm => vm.linkUrl}, vm => vm.linkUrl);
|
const link = t.a({href: vm => vm.linkUrl}, vm => vm.linkUrl);
|
||||||
return t.div({className: "CreateLinkView card"}, [
|
return t.div({className: "CreateLinkView card"}, [
|
||||||
t.h1(
|
t.h1("Create shareable links to Matrix rooms, users or messages without being tied to any app"),
|
||||||
{className: {hidden: vm => vm.previewViewModel}},
|
t.form({action: "#", onSubmit: evt => this._onSubmit(evt)}, [
|
||||||
"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.div(t.input({
|
t.div(t.input({
|
||||||
className: "fullwidth large",
|
className: "fullwidth large",
|
||||||
type: "text",
|
type: "text",
|
||||||
@ -52,7 +43,6 @@ export class CreateLinkView extends TemplateView {
|
|||||||
const {identifier} = form.elements;
|
const {identifier} = form.elements;
|
||||||
this.value.createLink(identifier.value);
|
this.value.createLink(identifier.value);
|
||||||
identifier.value = "";
|
identifier.value = "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onIdentifierChange(evt) {
|
_onIdentifierChange(evt) {
|
||||||
@ -63,10 +53,4 @@ export class CreateLinkView extends TemplateView {
|
|||||||
inputField.setCustomValidity("");
|
inputField.setCustomValidity("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_clear() {
|
|
||||||
this.value.clear();
|
|
||||||
const textField = this.root().querySelector("input[name=identifier]");
|
|
||||||
textField.focus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -32,28 +32,7 @@ export class CreateLinkViewModel extends ViewModel {
|
|||||||
async createLink(identifier) {
|
async createLink(identifier) {
|
||||||
this._link = Link.parse(identifier);
|
this._link = Link.parse(identifier);
|
||||||
if (this._link) {
|
if (this._link) {
|
||||||
// TODO: abort previous load
|
this.openLink("#" + this._link.toFragment());
|
||||||
this.previewViewModel = new PreviewViewModel(this.childOptions({
|
|
||||||
link: this._link,
|
|
||||||
consentedServers: this._link.servers,
|
|
||||||
}));
|
|
||||||
this.emitChange();
|
|
||||||
await this.previewViewModel.load();
|
|
||||||
} else {
|
|
||||||
this.previewViewModel = null;
|
|
||||||
}
|
|
||||||
this.emitChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
get linkUrl() {
|
|
||||||
if (this._link) {
|
|
||||||
return `${this.origin}/#${this._link.toFragment()}`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
|
||||||
this._link = null;
|
|
||||||
this.previewViewModel = null;
|
|
||||||
this.emitChange();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user