Make it easier to @mention the person to whom you are replying.

This commit is contained in:
Cory McWilliams 2024-04-04 00:50:59 +01:00
parent 4c8d24c319
commit 9671413906
3 changed files with 23 additions and 10 deletions

View File

@ -1,5 +1,5 @@
{ {
"type": "tildefriends-app", "type": "tildefriends-app",
"emoji": "🐌", "emoji": "🐌",
"previous": "&0WzpczDOhxawXBY8fAPMQWwOuF8bVRO+cMJJTxBpYOQ=.sha256" "previous": "&uSuRSjzMShdQllrt3gVYhWlixI6o6n0c1c/+pEhJCCI=.sha256"
} }

View File

@ -13,6 +13,7 @@ class TfComposeElement extends LitElement {
branch: {type: String}, branch: {type: String},
apps: {type: Object}, apps: {type: Object},
drafts: {type: Object}, drafts: {type: Object},
author: {type: String},
}; };
} }
@ -25,6 +26,7 @@ class TfComposeElement extends LitElement {
this.branch = undefined; this.branch = undefined;
this.apps = undefined; this.apps = undefined;
this.drafts = {}; this.drafts = {};
this.author = undefined;
} }
process_text(text) { process_text(text) {
@ -284,13 +286,25 @@ class TfComposeElement extends LitElement {
} }
firstUpdated() { firstUpdated() {
let values = Object.entries(this.users).map((x) => ({
key: x[1].name ?? x[0],
value: x[0],
}));
if (this.author) {
values = [].concat(
[
{
key: this.users[this.author]?.name,
value: this.author,
},
],
values
);
}
let tribute = new Tribute({ let tribute = new Tribute({
collection: [ collection: [
{ {
values: Object.entries(this.users).map((x) => ({ values: values,
key: x[1].name,
value: x[0],
})),
selectTemplate: function (item) { selectTemplate: function (item) {
return `[@${item.original.key}](${item.original.value})`; return `[@${item.original.key}](${item.original.value})`;
}, },
@ -542,8 +556,7 @@ class TfComposeElement extends LitElement {
@input=${this.input} @input=${this.input}
@change=${this.change} @change=${this.change}
@paste=${this.paste} @paste=${this.paste}
> >${draft.text}</textarea
${draft.text}</textarea
> >
</p> </p>
</div> </div>
@ -552,9 +565,7 @@ ${draft.text}</textarea
<div id="preview"></div> <div id="preview"></div>
</div> </div>
</div> </div>
${Object.values(draft.mentions || {}).map((x) => ${Object.values(draft.mentions || {}).map((x) => self.render_mention(x))}
self.render_mention(x)
)}
${this.render_attach_app()} ${this.render_content_warning()} ${this.render_attach_app()} ${this.render_content_warning()}
<button <button
class="w3-button w3-dark-grey" class="w3-button w3-dark-grey"

View File

@ -498,6 +498,7 @@ ${JSON.stringify(mention, null, 2)}</pre
branch=${this.message.id} branch=${this.message.id}
.drafts=${this.drafts} .drafts=${this.drafts}
@tf-discard=${this.discard_reply} @tf-discard=${this.discard_reply}
author=${this.message.author}
></tf-compose> ></tf-compose>
` `
: html` : html`
@ -685,6 +686,7 @@ ${JSON.stringify(content, null, 2)}</pre
branch=${this.message.id} branch=${this.message.id}
.drafts=${this.drafts} .drafts=${this.drafts}
@tf-discard=${this.discard_reply} @tf-discard=${this.discard_reply}
author=${this.message.author}
></tf-compose> ></tf-compose>
` `
: html` : html`