Fix some ssb compose issues.

This commit is contained in:
Cory McWilliams 2024-04-24 20:19:14 -04:00
parent b7b5d4f1a5
commit 93d46f5610
3 changed files with 9 additions and 12 deletions

View File

@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "🐌",
"previous": "&r2Xphgr4HGdG4WnqWngj8fcAs1xHfZ1a2DJgqr7hqZA=.sha256"
"previous": "&IknYNSKcVBOL5mY056kj4vUtd2IbW91LOl6KFwSqaWM=.sha256"
}

View File

@ -1,4 +1,4 @@
import {LitElement, html, unsafeHTML} from './lit-all.min.js';
import {LitElement, html, unsafeHTML, live} from './lit-all.min.js';
import * as tfutils from './tf-utils.js';
import * as tfrpc from '/static/tfrpc.js';
import {styles} from './tf-styles.js';
@ -66,7 +66,7 @@ class TfComposeElement extends LitElement {
updated = true;
}
if (updated) {
this.requestUpdate();
setTimeout(() => this.notify(draft), 0);
}
return tfutils.markdown(text);
}
@ -301,14 +301,14 @@ class TfComposeElement extends LitElement {
{
values: values,
selectTemplate: function (item) {
return `[@${item.original.key}](${item.original.value})`;
return item ? `[@${item.original.key}](${item.original.value})` : undefined;
},
},
{
trigger: '&',
values: this.autocomplete,
selectTemplate: function (item) {
return `![${item.original.key}](${item.original.value})`;
return item ? `![${item.original.key}](${item.original.value})` : undefined;
},
},
],
@ -342,8 +342,7 @@ class TfComposeElement extends LitElement {
remove_mention(id) {
let draft = this.get_draft();
delete draft.mentions[id];
this.notify(draft);
this.requestUpdate();
setTimeout(() => this.requestUpdate(), 0);
}
render_mention(mention) {
@ -550,8 +549,8 @@ class TfComposeElement extends LitElement {
@input=${this.input}
@paste=${this.paste}
contenteditable
>${draft.text}</span
>
innerText=${live(draft.text)}
></span>
</div>
<div class="w3-half w3-padding">
${content_warning}

View File

@ -85,9 +85,7 @@ class TfTabNewsElement extends LitElement {
delete this.drafts[id];
}
/* Only trigger a re-render if we're creating a new draft or discarding an old one. */
if ((previous !== undefined) != (event.detail.draft !== undefined)) {
this.drafts = Object.assign({}, this.drafts);
}
this.drafts = Object.assign({}, this.drafts);
tfrpc.rpc.localStorageSet('drafts', JSON.stringify(this.drafts));
}