ssb: Better handling of private message drafts.

This commit is contained in:
2025-08-13 19:53:28 -04:00
parent 7cec0f7d61
commit f378db6c6f
4 changed files with 16 additions and 3 deletions

View File

@@ -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) {

View File

@@ -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

View File

@@ -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}
></tf-compose>
</div>
${profile}