From 45231d703d99cb472cf1e5876ea8ee6198572874 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 4 Jun 2025 18:00:46 -0400 Subject: [PATCH] ssb: Split recent votes into their own sidebar item as an experiment. #122 --- apps/ssb.json | 2 +- apps/ssb/tf-app.js | 8 +++++++- apps/ssb/tf-tab-news-feed.js | 22 ++++++++++++++++++++++ apps/ssb/tf-tab-news.js | 6 ++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index e4775875..8725a95e 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "πŸ¦€", - "previous": "&JfWdlllyfUCzLARI/4tNR1Xlfx8nN3ONBSCipVhGd6g=.sha256" + "previous": "&GMCcwEOE3VorFHqMCRi6aS1Ch7u1B7hzW6GH35RaaUI=.sha256" } diff --git a/apps/ssb/tf-app.js b/apps/ssb/tf-app.js index 8cd401d3..d2da5654 100644 --- a/apps/ssb/tf-app.js +++ b/apps/ssb/tf-app.js @@ -128,7 +128,7 @@ class TfElement extends LitElement { } next_channel(delta) { - let channel_names = ['', '@', 'πŸ”', ...this.channels.map((x) => '#' + x)]; + let channel_names = ['', '@', 'πŸ”', 'πŸ‘', ...this.channels.map((x) => '#' + x)]; let index = channel_names.indexOf(this.hash.substring(1)); index = index != -1 ? index + delta : 0; tfrpc.rpc.setHash( @@ -383,6 +383,12 @@ class TfElement extends LitElement { JOIN messages ON messages.rowid = messages_fts.rowid JOIN json_each(?2) AS following ON messages.author = following.value WHERE messages.author != ?4 + UNION + SELECT 'πŸ‘' AS channel, MAX(messages.rowid) AS rowid FROM messages + JOIN json_each(?2) AS following ON messages.author = following.value + WHERE + messages.content ->> 'type' = 'vote' AND + messages.author != ?4 `, [ JSON.stringify(this.channels), diff --git a/apps/ssb/tf-tab-news-feed.js b/apps/ssb/tf-tab-news-feed.js index 425c4362..7d77feaf 100644 --- a/apps/ssb/tf-tab-news-feed.js +++ b/apps/ssb/tf-tab-news-feed.js @@ -214,6 +214,28 @@ class TfTabNewsFeedElement extends LitElement { [JSON.stringify(this.private_messages), start_time, end_time] ); result = (await this.decrypt(result)).filter((x) => x.decrypted); + } else if (this.hash == '#πŸ‘') { + result = await tfrpc.rpc.query( + ` + WITH votes AS (SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature + FROM messages + JOIN json_each(?1) AS following ON messages.author = following.value + WHERE + messages.content ->> 'type' = 'vote' AND + (?2 IS NULL OR messages.timestamp >= ?2) AND messages.timestamp < ?3 + ORDER BY timestamp DESC limit 20) + SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature + FROM votes + JOIN messages ON messages.id = votes.content ->> '$.vote.link' + UNION + SELECT TRUE AS is_primary, * FROM votes + `, + [ + JSON.stringify(this.following), + start_time, + end_time, + ] + ); } else { let t0 = new Date(); let initial_messages = await tfrpc.rpc.query( diff --git a/apps/ssb/tf-tab-news.js b/apps/ssb/tf-tab-news.js index 69bb2978..4196ddb2 100644 --- a/apps/ssb/tf-tab-news.js +++ b/apps/ssb/tf-tab-news.js @@ -202,6 +202,12 @@ class TfTabNewsElement extends LitElement { style=${this.hash == '#@' ? 'font-weight: bold' : undefined} >${this.unread_status('@')}@mentions + ${this.unread_status('πŸ‘')}πŸ‘votes