ssb: Unread status for private messages.

This commit is contained in:
2025-08-14 12:40:58 -04:00
parent d78828554b
commit 00f75d5382
4 changed files with 20 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
{ {
"type": "tildefriends-app", "type": "tildefriends-app",
"emoji": "🦀", "emoji": "🦀",
"previous": "&vvbZ1UaJgi4mVonUOmevMO4iB1tL70vhCA/Jo8tnaX4=.sha256" "previous": "&kkfTptI7rzqHIPlOR9UkiekpZuyMtR/4W8KVQ8jeOVw=.sha256"
} }

View File

@@ -374,7 +374,7 @@ class TfElement extends LitElement {
let result = await this.decrypt( let result = await this.decrypt(
await tfrpc.rpc.query( await tfrpc.rpc.query(
` `
SELECT messages.id, author, timestamp, json(content) AS content SELECT messages.rowid, messages.id, author, timestamp, json(content) AS content
FROM messages FROM messages
JOIN json_each(?) AS ids JOIN json_each(?) AS ids
WHERE messages.id = ids.value WHERE messages.id = ids.value

View File

@@ -92,7 +92,9 @@ class TfComposeElement extends LitElement {
bubbles: true, bubbles: true,
composed: true, composed: true,
detail: { detail: {
id: this.branch ?? (this.recipients ? this.recipients.join(',') : undefined), id:
this.branch ??
(this.recipients ? this.recipients.join(',') : undefined),
draft: draft, draft: draft,
}, },
}) })

View File

@@ -116,6 +116,19 @@ class TfTabNewsElement extends LitElement {
) { ) {
return '✉️ '; return '✉️ ';
} }
} else if (channel?.startsWith('🔐')) {
let key = JSON.stringify(channel.substring('🔐'.length).split(','));
if (this.grouped_private_messages?.[key]) {
let grouped_latest = Math.max(
...this.grouped_private_messages?.[key]?.map((x) => x.rowid)
);
if (
this.channels_unread[channel] === undefined ||
grouped_latest > this.channels_unread[channel]
) {
return '✉️ ';
}
}
} else if ( } else if (
this.channels_latest[channel] && this.channels_latest[channel] &&
this.channels_latest[channel] > 0 && this.channels_latest[channel] > 0 &&
@@ -268,7 +281,8 @@ class TfTabNewsElement extends LitElement {
style=${this.hash == '#🔐' + JSON.parse(key).join(',') style=${this.hash == '#🔐' + JSON.parse(key).join(',')
? 'font-weight: bold' ? 'font-weight: bold'
: undefined} : undefined}
>${(key != '[]' ? JSON.parse(key) : [this.whoami]).map( >${this.unread_status('🔐' + JSON.parse(key).join(','))}
${(key != '[]' ? JSON.parse(key) : [this.whoami]).map(
(id) => html` (id) => html`
<tf-user <tf-user
id=${id} id=${id}