ssb: Show/hide "Mark All Read" and the unread line more correctly.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 32m53s

This commit is contained in:
2025-06-11 19:22:21 -04:00
parent cbf1273a55
commit 2a6789063e
3 changed files with 22 additions and 8 deletions

View File

@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "🦀",
"previous": "&Bpf8wmdsVYGPSBduytapHM7XHz2iCGfaysVHfEKYK/s=.sha256"
"previous": "&XDrMZT7w656QanwG+zRSUFeaoY3Jl4elveY6GftcD5Y=.sha256"
}

View File

@ -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`

View File

@ -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`
<p>
<button class="w3-button w3-theme-d1" @click=${this.mark_all_read}>
Mark All Read
</button>
${this.unread_allowed() ? html`
<button class="w3-button w3-theme-d1" @click=${this.mark_all_read}>
Mark All Read
</button>
` : undefined}
<button
?disabled=${this.loading}
class="w3-button w3-theme-d1"
@ -458,7 +464,7 @@ class TfTabNewsFeedElement extends LitElement {
`;
}
return cache(html`
${!this.hash.startsWith('#%')
${this.unread_allowed()
? html`<button
class="w3-button w3-theme-d1"
@click=${this.mark_all_read}
@ -474,6 +480,7 @@ class TfTabNewsFeedElement extends LitElement {
.following=${this.following}
.drafts=${this.drafts}
.expanded=${this.expanded}
hash=${this.hash}
channel=${this.channel()}
channel_unread=${this.channels_unread?.[this.channel()]}
.recent_reactions=${this.recent_reactions}