From 2a6789063e184ce9bd73154447c979bd4a854a93 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 11 Jun 2025 19:22:21 -0400 Subject: [PATCH] ssb: Show/hide "Mark All Read" and the unread line more correctly. --- apps/ssb.json | 2 +- apps/ssb/tf-news.js | 13 ++++++++++--- apps/ssb/tf-tab-news-feed.js | 15 +++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index d6538d98..cb6781ed 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🦀", - "previous": "&Bpf8wmdsVYGPSBduytapHM7XHz2iCGfaysVHfEKYK/s=.sha256" + "previous": "&XDrMZT7w656QanwG+zRSUFeaoY3Jl4elveY6GftcD5Y=.sha256" } diff --git a/apps/ssb/tf-news.js b/apps/ssb/tf-news.js index aea87e6f..a41aa3fc 100644 --- a/apps/ssb/tf-news.js +++ b/apps/ssb/tf-news.js @@ -14,6 +14,7 @@ class TfNewsElement extends LitElement { channel: {type: String}, channel_unread: {type: Number}, recent_reactions: {type: Array}, + hash: {type: String}, }; } @@ -193,15 +194,21 @@ class TfNewsElement extends LitElement { return result; } + unread_allowed() { + return !this.hash?.startsWith('#%') && !this.hash?.startsWith('#@'); + } + load_and_render(messages) { let messages_by_id = this.process_messages(messages); let final_messages = this.group_following( this.finalize_messages(messages_by_id) ); let unread_rowid = -1; - for (let message of final_messages) { - if (message.rowid >= this.channel_unread) { - unread_rowid = message.rowid; + if (this.unread_allowed()) { + for (let message of final_messages) { + if (message.rowid >= this.channel_unread) { + unread_rowid = message.rowid; + } } } return html` diff --git a/apps/ssb/tf-tab-news-feed.js b/apps/ssb/tf-tab-news-feed.js index e3eda0ac..7ad1a62a 100644 --- a/apps/ssb/tf-tab-news-feed.js +++ b/apps/ssb/tf-tab-news-feed.js @@ -275,6 +275,10 @@ class TfTabNewsFeedElement extends LitElement { ]; } + unread_allowed() { + return !this.hash.startsWith('#%') && !this.hash.startsWith('#@'); + } + async load_more() { this.loading++; this.loading_canceled = false; @@ -424,9 +428,11 @@ class TfTabNewsFeedElement extends LitElement { if (!this.hash.startsWith('#%')) { more = html`

- + ${this.unread_allowed() ? html` + + ` : undefined}