From e5899fca58070fa504a1a529286cd59f6ffbe628 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 5 Feb 2025 18:41:37 -0500 Subject: [PATCH] ssb: Use the cache of private messages we built for the unread notification to actually show private messages. Still needs some work, but it's something. --- apps/ssb.json | 2 +- apps/ssb/tf-app.js | 8 ++++++-- apps/ssb/tf-tab-news-feed.js | 5 +++-- apps/ssb/tf-tab-news.js | 2 ++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index b4a19ae9..3b5822e4 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🦀", - "previous": "&zAW/4XKD1wcsEM12bkzZD0V7Wyne3OPpQne2rtncxXM=.sha256" + "previous": "&0ZtxnihH3oETfi0vhhEwc9O66SrjfiFcHDVBAIxICy0=.sha256" } diff --git a/apps/ssb/tf-app.js b/apps/ssb/tf-app.js index 83b88fcd..12f99e80 100644 --- a/apps/ssb/tf-app.js +++ b/apps/ssb/tf-app.js @@ -20,6 +20,7 @@ class TfElement extends LitElement { channels_latest: {type: Object}, guest: {type: Boolean}, url: {type: String}, + private_messages: {type: Array}, }; } @@ -334,7 +335,7 @@ class TfElement extends LitElement { JSON.stringify(cache) ); } - return cache.latest; + return [cache.latest, cache.messages]; } async load_channels_latest(following) { @@ -378,9 +379,11 @@ class TfElement extends LitElement { start_time = new Date(); latest_private.then(function (latest) { self.channels_latest = Object.assign({}, self.channels_latest, { - '🔐': latest, + '🔐': latest[0], }); console.log('private took', (new Date() - start_time) / 1000.0); + console.log(latest); + self.private_messages = latest[1]; }); } @@ -513,6 +516,7 @@ class TfElement extends LitElement { .channels_unread=${this.channels_unread} @channelsetunread=${this.channel_set_unread} .connections=${this.connections} + .private_messages=${this.private_messages} > `; } else if (this.tab === 'connections') { diff --git a/apps/ssb/tf-tab-news-feed.js b/apps/ssb/tf-tab-news-feed.js index 06ad9622..6cecdbc1 100644 --- a/apps/ssb/tf-tab-news-feed.js +++ b/apps/ssb/tf-tab-news-feed.js @@ -17,6 +17,7 @@ class TfTabNewsFeedElement extends LitElement { loading: {type: Number}, time_range: {type: Array}, time_loading: {type: Array}, + private_messages: {type: Array}, }; } @@ -148,13 +149,13 @@ class TfTabNewsFeedElement extends LitElement { ` SELECT TRUE AS is_primary, messages.rowid, messages.id, previous, author, sequence, timestamp, hash, json(content) AS content, signature FROM messages - JOIN json_each(?1) AS following ON messages.author = following.value + JOIN json_each(?1) AS private_messages ON messages.id = private_messages.value WHERE (?2 IS NULL OR (messages.timestamp >= ?2)) AND messages.timestamp < ?3 AND json(messages.content) LIKE '"%' ORDER BY messages.sequence DESC LIMIT 20 `, - [JSON.stringify(this.following), start_time, end_time] + [JSON.stringify(this.private_messages), start_time, end_time] ); result = (await this.decrypt(result)).filter((x) => x.decrypted); } else { diff --git a/apps/ssb/tf-tab-news.js b/apps/ssb/tf-tab-news.js index 5c24931c..1de22e1d 100644 --- a/apps/ssb/tf-tab-news.js +++ b/apps/ssb/tf-tab-news.js @@ -23,6 +23,7 @@ class TfTabNewsElement extends LitElement { channels_unread: {type: Object}, channels_latest: {type: Object}, connections: {type: Array}, + private_messages: {type: Array}, }; } @@ -337,6 +338,7 @@ class TfTabNewsElement extends LitElement { @tf-expand=${this.on_expand} .channels_unread=${this.channels_unread} .channels_latest=${this.channels_latest} + .private_messages=${this.private_messages} >