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
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 32m53s
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🦀",
|
"emoji": "🦀",
|
||||||
"previous": "&Bpf8wmdsVYGPSBduytapHM7XHz2iCGfaysVHfEKYK/s=.sha256"
|
"previous": "&XDrMZT7w656QanwG+zRSUFeaoY3Jl4elveY6GftcD5Y=.sha256"
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ class TfNewsElement extends LitElement {
|
|||||||
channel: {type: String},
|
channel: {type: String},
|
||||||
channel_unread: {type: Number},
|
channel_unread: {type: Number},
|
||||||
recent_reactions: {type: Array},
|
recent_reactions: {type: Array},
|
||||||
|
hash: {type: String},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,17 +194,23 @@ class TfNewsElement extends LitElement {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unread_allowed() {
|
||||||
|
return !this.hash?.startsWith('#%') && !this.hash?.startsWith('#@');
|
||||||
|
}
|
||||||
|
|
||||||
load_and_render(messages) {
|
load_and_render(messages) {
|
||||||
let messages_by_id = this.process_messages(messages);
|
let messages_by_id = this.process_messages(messages);
|
||||||
let final_messages = this.group_following(
|
let final_messages = this.group_following(
|
||||||
this.finalize_messages(messages_by_id)
|
this.finalize_messages(messages_by_id)
|
||||||
);
|
);
|
||||||
let unread_rowid = -1;
|
let unread_rowid = -1;
|
||||||
|
if (this.unread_allowed()) {
|
||||||
for (let message of final_messages) {
|
for (let message of final_messages) {
|
||||||
if (message.rowid >= this.channel_unread) {
|
if (message.rowid >= this.channel_unread) {
|
||||||
unread_rowid = message.rowid;
|
unread_rowid = message.rowid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return html`
|
return html`
|
||||||
<div>
|
<div>
|
||||||
${repeat(
|
${repeat(
|
||||||
|
@ -275,6 +275,10 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unread_allowed() {
|
||||||
|
return !this.hash.startsWith('#%') && !this.hash.startsWith('#@');
|
||||||
|
}
|
||||||
|
|
||||||
async load_more() {
|
async load_more() {
|
||||||
this.loading++;
|
this.loading++;
|
||||||
this.loading_canceled = false;
|
this.loading_canceled = false;
|
||||||
@ -424,9 +428,11 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
if (!this.hash.startsWith('#%')) {
|
if (!this.hash.startsWith('#%')) {
|
||||||
more = html`
|
more = html`
|
||||||
<p>
|
<p>
|
||||||
|
${this.unread_allowed() ? html`
|
||||||
<button class="w3-button w3-theme-d1" @click=${this.mark_all_read}>
|
<button class="w3-button w3-theme-d1" @click=${this.mark_all_read}>
|
||||||
Mark All Read
|
Mark All Read
|
||||||
</button>
|
</button>
|
||||||
|
` : undefined}
|
||||||
<button
|
<button
|
||||||
?disabled=${this.loading}
|
?disabled=${this.loading}
|
||||||
class="w3-button w3-theme-d1"
|
class="w3-button w3-theme-d1"
|
||||||
@ -458,7 +464,7 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
return cache(html`
|
return cache(html`
|
||||||
${!this.hash.startsWith('#%')
|
${this.unread_allowed()
|
||||||
? html`<button
|
? html`<button
|
||||||
class="w3-button w3-theme-d1"
|
class="w3-button w3-theme-d1"
|
||||||
@click=${this.mark_all_read}
|
@click=${this.mark_all_read}
|
||||||
@ -474,6 +480,7 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
.following=${this.following}
|
.following=${this.following}
|
||||||
.drafts=${this.drafts}
|
.drafts=${this.drafts}
|
||||||
.expanded=${this.expanded}
|
.expanded=${this.expanded}
|
||||||
|
hash=${this.hash}
|
||||||
channel=${this.channel()}
|
channel=${this.channel()}
|
||||||
channel_unread=${this.channels_unread?.[this.channel()]}
|
channel_unread=${this.channels_unread?.[this.channel()]}
|
||||||
.recent_reactions=${this.recent_reactions}
|
.recent_reactions=${this.recent_reactions}
|
||||||
|
Reference in New Issue
Block a user