From 8a27c45ab125c8de31853aae68e4f747ce92e919 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 4 Dec 2024 20:50:46 -0500 Subject: [PATCH] ssb: An experiment in including hashtag mentions in channel content. Also sort the channel list like I thought I already did. --- apps/ssb.json | 2 +- apps/ssb/tf-app.js | 2 +- apps/ssb/tf-tab-news-feed.js | 24 +++++++++++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index 6115a06a2..0ea7a0020 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🐌", - "previous": "&CYrIO97YKzR9kzp6sfWVx0g+xah9iuF8BlOg9EDMgMk=.sha256" + "previous": "&+H2UcjXWpt50AtiIz8Uac38RJgLshQ0lAAH8Gb5/DNs=.sha256" } diff --git a/apps/ssb/tf-app.js b/apps/ssb/tf-app.js index 7e9e92833..76792fce4 100644 --- a/apps/ssb/tf-app.js +++ b/apps/ssb/tf-app.js @@ -91,7 +91,7 @@ class TfElement extends LitElement { delete channel_map[row.channel]; } } - this.channels = Object.keys(channel_map); + this.channels = Object.keys(channel_map).sort(); } set_hash(hash) { diff --git a/apps/ssb/tf-tab-news-feed.js b/apps/ssb/tf-tab-news-feed.js index 956f09554..3eb93ca7e 100644 --- a/apps/ssb/tf-tab-news-feed.js +++ b/apps/ssb/tf-tab-news-feed.js @@ -80,13 +80,13 @@ class TfTabNewsFeedElement extends LitElement { tfrpc.rpc.query( ` WITH news 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(?) AS following ON messages.author = following.value - WHERE - messages.timestamp > ? AND - messages.timestamp < ? AND - messages.content ->> 'channel' = ? - ORDER BY messages.timestamp DESC) + FROM messages + JOIN json_each(?) AS following ON messages.author = following.value + WHERE + messages.timestamp > ? AND + messages.timestamp < ? AND + messages.content ->> 'channel' = ? + ORDER BY messages.timestamp DESC) SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature FROM news JOIN messages_refs ON news.id = messages_refs.ref @@ -97,6 +97,15 @@ class TfTabNewsFeedElement extends LitElement { JOIN messages_refs ON news.id = messages_refs.message JOIN messages ON messages_refs.ref = messages.id UNION + SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature + FROM messages_fts(?5) + JOIN messages ON messages.rowid = messages_fts.rowid + JOIN json_each(?1) AS following ON messages.author = following.value + JOIN json_tree(messages.content, '$.mentions') AS mention ON mention.value = '#' || ?4 + WHERE + messages.timestamp > ?2 AND + messages.timestamp < ?3 + UNION SELECT news.* FROM news `, [ @@ -104,6 +113,7 @@ class TfTabNewsFeedElement extends LitElement { start_time, end_time, this.hash.substring(2), + '"#' + this.hash.substring(2).replace('"', '""') + '"', ] ) );