From f378db6c6f9cccabd4c463ece0d65ea22ba835a8 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 13 Aug 2025 19:53:28 -0400 Subject: [PATCH] ssb: Better handling of private message drafts. --- apps/ssb.json | 2 +- apps/ssb/tf-compose.js | 13 ++++++++++++- apps/ssb/tf-tab-news-feed.js | 1 - apps/ssb/tf-tab-news.js | 3 +++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index 6a09f0f7b..d79067482 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🦀", - "previous": "&5T+xPy3LhgmU2ape4dlJLRhYhmE5J1SQkI+wFm6Fss4=.sha256" + "previous": "&K4alfggWhsPlQs0PMLJqvpm03SFmcDs1xlVwnwYCS4k=.sha256" } diff --git a/apps/ssb/tf-compose.js b/apps/ssb/tf-compose.js index 25ea2303e..bd592e93a 100644 --- a/apps/ssb/tf-compose.js +++ b/apps/ssb/tf-compose.js @@ -16,6 +16,7 @@ class TfComposeElement extends LitElement { author: {type: String}, channel: {type: String}, new_thread: {type: Boolean}, + recipients: {type: Array}, }; } @@ -496,7 +497,17 @@ class TfComposeElement extends LitElement { } get_draft() { - return this.drafts[this.branch || ''] || {}; + let key = + this.branch || + (this.recipients ? this.recipients.join(',') : undefined) || + ''; + let draft = this.drafts[key] || {}; + if (this.recipients && !draft.encrypt_to?.length) { + draft.encrypt_to = [ + ...new Set(this.recipients).union(new Set(draft.encrypt_to ?? [])), + ]; + } + return draft; } update_encrypt(event) { diff --git a/apps/ssb/tf-tab-news-feed.js b/apps/ssb/tf-tab-news-feed.js index 5bc3f5903..ed48448ae 100644 --- a/apps/ssb/tf-tab-news-feed.js +++ b/apps/ssb/tf-tab-news-feed.js @@ -230,7 +230,6 @@ class TfTabNewsFeedElement extends LitElement { result = (await this.decrypt(result)).filter((x) => x.decrypted); } else if (this.hash.startsWith('#🔐')) { let ids = this.hash.substring('#🔐'.length).split(','); - console.log(this.grouped_private_messages); result = await tfrpc.rpc.query( ` SELECT TRUE AS is_primary, messages.rowid, messages.id, previous, author, sequence, timestamp, hash, json(content) AS content, signature diff --git a/apps/ssb/tf-tab-news.js b/apps/ssb/tf-tab-news.js index 9f7162a80..c08e4370b 100644 --- a/apps/ssb/tf-tab-news.js +++ b/apps/ssb/tf-tab-news.js @@ -435,6 +435,9 @@ class TfTabNewsElement extends LitElement { .drafts=${this.drafts} @tf-draft=${this.draft} .channel=${this.channel()} + .recipients=${this.hash.startsWith('#🔐') + ? this.hash.substring('#🔐'.length).split(',') + : undefined} > ${profile}