Some fixes for drafts on threads.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4142 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-01-21 19:12:55 +00:00
parent f841ca4399
commit 2420869e7f
3 changed files with 5 additions and 6 deletions

View File

@ -69,7 +69,7 @@ class TfComposeElement extends LitElement {
change(event) {
let edit = this.renderRoot.getElementById('edit');
this.dispatchEvent(new CustomEvent('tf-draft', {detail: {id: this.branch, draft: edit.value, bubbles: true}}));
this.dispatchEvent(new CustomEvent('tf-draft', {bubbles: true, composed: true, detail: {id: this.branch, draft: edit.value}}));
}
convert_to_format(buffer, type, mime_type) {
@ -107,7 +107,6 @@ class TfComposeElement extends LitElement {
let best_type;
for (let format of ['image/png', 'image/jpeg', 'image/webp']) {
let test_buffer = await self.convert_to_format(buffer, file.type, format);
console.log(format, test_buffer.length);
if (!best_buffer || test_buffer.length < best_buffer.length) {
best_buffer = test_buffer;
best_type = format;
@ -269,8 +268,9 @@ class TfComposeElement extends LitElement {
render() {
let self = this;
let result = html`
<div>${JSON.stringify(this.drafts)}</div>
<div style="display: flex; flex-direction: row; width: 100%">
<textarea id="edit" @input=${this.input} @change=${this.change} @paste=${this.paste} style="flex: 1 0 50%">${this.drafts[this.id || '']}</textarea>
<textarea id="edit" @input=${this.input} @change=${this.change} @paste=${this.paste} style="flex: 1 0 50%">${this.drafts[this.branch || '']}</textarea>
<div id="preview" style="flex: 1 0 50%"></div>
</div>
${Object.values(this.mentions).map(x => self.render_mention(x))}

View File

@ -38,7 +38,6 @@ class TfMessageElement extends LitElement {
}
discard_reply() {
console.log('discard');
this.dispatchEvent(new CustomEvent('tf-draft', {bubbles: true, composed: true, detail: {id: this.id, draft: undefined}}));
}
@ -282,6 +281,7 @@ class TfMessageElement extends LitElement {
.users=${this.users}
root=${this.message.content.root || this.message.id}
branch=${this.message.id}
.drafts=${this.drafts}
@tf-discard=${this.discard_reply}></tf-compose>
` : html`
<input type="button" value="Reply" @click=${this.show_reply}></input>
@ -340,7 +340,6 @@ class TfMessageElement extends LitElement {
`;
} else if (content.type === 'blog') {
let self = this;
console.log('requesting data');
tfrpc.rpc.get_blob(content.blog).then(function(data) {
self.blog_data = data;
});