From 00f75d5382ee3c46ffc9b8b96a4f1650f366e9e7 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 14 Aug 2025 12:40:58 -0400 Subject: [PATCH] ssb: Unread status for private messages. --- apps/ssb.json | 2 +- apps/ssb/tf-app.js | 2 +- apps/ssb/tf-compose.js | 4 +++- apps/ssb/tf-tab-news.js | 16 +++++++++++++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index 63bdd26be..1acdb4857 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🦀", - "previous": "&vvbZ1UaJgi4mVonUOmevMO4iB1tL70vhCA/Jo8tnaX4=.sha256" + "previous": "&kkfTptI7rzqHIPlOR9UkiekpZuyMtR/4W8KVQ8jeOVw=.sha256" } diff --git a/apps/ssb/tf-app.js b/apps/ssb/tf-app.js index 8b9df515b..a6e27cecf 100644 --- a/apps/ssb/tf-app.js +++ b/apps/ssb/tf-app.js @@ -374,7 +374,7 @@ class TfElement extends LitElement { let result = await this.decrypt( 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 JOIN json_each(?) AS ids WHERE messages.id = ids.value diff --git a/apps/ssb/tf-compose.js b/apps/ssb/tf-compose.js index 56d215ae3..c55247dd4 100644 --- a/apps/ssb/tf-compose.js +++ b/apps/ssb/tf-compose.js @@ -92,7 +92,9 @@ class TfComposeElement extends LitElement { bubbles: true, composed: true, detail: { - id: this.branch ?? (this.recipients ? this.recipients.join(',') : undefined), + id: + this.branch ?? + (this.recipients ? this.recipients.join(',') : undefined), draft: draft, }, }) diff --git a/apps/ssb/tf-tab-news.js b/apps/ssb/tf-tab-news.js index c08e4370b..d4b01ee61 100644 --- a/apps/ssb/tf-tab-news.js +++ b/apps/ssb/tf-tab-news.js @@ -116,6 +116,19 @@ class TfTabNewsElement extends LitElement { ) { 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 ( this.channels_latest[channel] && this.channels_latest[channel] > 0 && @@ -268,7 +281,8 @@ class TfTabNewsElement extends LitElement { style=${this.hash == '#🔐' + JSON.parse(key).join(',') ? 'font-weight: bold' : undefined} - >${(key != '[]' ? JSON.parse(key) : [this.whoami]).map( + >${this.unread_status('🔐' + JSON.parse(key).join(','))} + ${(key != '[]' ? JSON.parse(key) : [this.whoami]).map( (id) => html`