ssb: Fix some unread marker issues.
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled

This commit is contained in:
Cory McWilliams 2024-12-18 12:43:25 -05:00
parent a9aa928629
commit 53717076f5
2 changed files with 9 additions and 8 deletions

View File

@ -1,5 +1,5 @@
{ {
"type": "tildefriends-app", "type": "tildefriends-app",
"emoji": "🐌", "emoji": "🐌",
"previous": "&tkrwd7UkPaWUk9189g3D08N44EjT0AJOlDLw6oMfbpY=.sha256" "previous": "&5mQzvcGxx+TD4O8INR+KPO6dxbb+7p8IchL44TWSrgE=.sha256"
} }

View File

@ -36,12 +36,13 @@ class TfNewsElement extends LitElement {
console.log('processing', messages.length, 'messages'); console.log('processing', messages.length, 'messages');
function ensure_message(id) { function ensure_message(id, rowid) {
let found = messages_by_id[id]; let found = messages_by_id[id];
if (found) { if (found) {
return found; return found;
} else { } else {
let added = { let added = {
rowid: rowid,
id: id, id: id,
placeholder: true, placeholder: true,
content: '"placeholder"', content: '"placeholder"',
@ -56,7 +57,7 @@ class TfNewsElement extends LitElement {
function link_message(message) { function link_message(message) {
if (message.content.type === 'vote') { if (message.content.type === 'vote') {
let parent = ensure_message(message.content.vote.link); let parent = ensure_message(message.content.vote.link, message.rowid);
if (!parent.votes) { if (!parent.votes) {
parent.votes = []; parent.votes = [];
} }
@ -65,14 +66,14 @@ class TfNewsElement extends LitElement {
} else if (message.content.type == 'post') { } else if (message.content.type == 'post') {
if (message.content.root) { if (message.content.root) {
if (typeof message.content.root === 'string') { if (typeof message.content.root === 'string') {
let m = ensure_message(message.content.root); let m = ensure_message(message.content.root, message.rowid);
if (!m.child_messages) { if (!m.child_messages) {
m.child_messages = []; m.child_messages = [];
} }
m.child_messages.push(message); m.child_messages.push(message);
message.parent_message = message.content.root; message.parent_message = message.content.root;
} else { } else {
let m = ensure_message(message.content.root[0]); let m = ensure_message(message.content.root[0], message.rowid);
if (!m.child_messages) { if (!m.child_messages) {
m.child_messages = []; m.child_messages = [];
} }
@ -191,16 +192,16 @@ class TfNewsElement extends LitElement {
); );
let unread_rowid = -1; let unread_rowid = -1;
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;
break;
} }
} }
return html` return html`
<div> <div>
${final_messages.map( ${final_messages.map(
(x) => (x) =>
html` ${x.rowid == unread_rowid && x != final_messages[0] html`
${x.rowid == unread_rowid && x != final_messages[0]
? html`<div style="display: flex; flex-direction: row"> ? html`<div style="display: flex; flex-direction: row">
<div <div
style="border-bottom: 1px solid #f00; flex: 1; align-self: center; height: 1px" style="border-bottom: 1px solid #f00; flex: 1; align-self: center; height: 1px"