From 967141390634c69c5eabd2142db2ec091dd6c344 Mon Sep 17 00:00:00 2001
From: Cory McWilliams
Date: Thu, 4 Apr 2024 00:50:59 +0100
Subject: [PATCH] Make it easier to @mention the person to whom you are
replying.
---
apps/ssb.json | 2 +-
apps/ssb/tf-compose.js | 29 ++++++++++++++++++++---------
apps/ssb/tf-message.js | 2 ++
3 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/apps/ssb.json b/apps/ssb.json
index 71608ef3..272212ad 100644
--- a/apps/ssb.json
+++ b/apps/ssb.json
@@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "🐌",
- "previous": "&0WzpczDOhxawXBY8fAPMQWwOuF8bVRO+cMJJTxBpYOQ=.sha256"
+ "previous": "&uSuRSjzMShdQllrt3gVYhWlixI6o6n0c1c/+pEhJCCI=.sha256"
}
diff --git a/apps/ssb/tf-compose.js b/apps/ssb/tf-compose.js
index 7ecf0155..039665fc 100644
--- a/apps/ssb/tf-compose.js
+++ b/apps/ssb/tf-compose.js
@@ -13,6 +13,7 @@ class TfComposeElement extends LitElement {
branch: {type: String},
apps: {type: Object},
drafts: {type: Object},
+ author: {type: String},
};
}
@@ -25,6 +26,7 @@ class TfComposeElement extends LitElement {
this.branch = undefined;
this.apps = undefined;
this.drafts = {};
+ this.author = undefined;
}
process_text(text) {
@@ -284,13 +286,25 @@ class TfComposeElement extends LitElement {
}
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({
collection: [
{
- values: Object.entries(this.users).map((x) => ({
- key: x[1].name,
- value: x[0],
- })),
+ values: values,
selectTemplate: function (item) {
return `[@${item.original.key}](${item.original.value})`;
},
@@ -542,8 +556,7 @@ class TfComposeElement extends LitElement {
@input=${this.input}
@change=${this.change}
@paste=${this.paste}
- >
-${draft.text}${draft.text}
@@ -552,9 +565,7 @@ ${draft.text}
- ${Object.values(draft.mentions || {}).map((x) =>
- self.render_mention(x)
- )}
+ ${Object.values(draft.mentions || {}).map((x) => self.render_mention(x))}
${this.render_attach_app()} ${this.render_content_warning()}