From 53717076f5a417cd85ff078b645bd27cf18bbeaf Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 18 Dec 2024 12:43:25 -0500 Subject: [PATCH] ssb: Fix some unread marker issues. --- apps/ssb.json | 2 +- apps/ssb/tf-news.js | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index a500bb84..c3c75444 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🐌", - "previous": "&tkrwd7UkPaWUk9189g3D08N44EjT0AJOlDLw6oMfbpY=.sha256" + "previous": "&5mQzvcGxx+TD4O8INR+KPO6dxbb+7p8IchL44TWSrgE=.sha256" } diff --git a/apps/ssb/tf-news.js b/apps/ssb/tf-news.js index 62df710a..be19d077 100644 --- a/apps/ssb/tf-news.js +++ b/apps/ssb/tf-news.js @@ -36,12 +36,13 @@ class TfNewsElement extends LitElement { console.log('processing', messages.length, 'messages'); - function ensure_message(id) { + function ensure_message(id, rowid) { let found = messages_by_id[id]; if (found) { return found; } else { let added = { + rowid: rowid, id: id, placeholder: true, content: '"placeholder"', @@ -56,7 +57,7 @@ class TfNewsElement extends LitElement { function link_message(message) { 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) { parent.votes = []; } @@ -65,14 +66,14 @@ class TfNewsElement extends LitElement { } else if (message.content.type == 'post') { if (message.content.root) { 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) { m.child_messages = []; } m.child_messages.push(message); message.parent_message = message.content.root; } else { - let m = ensure_message(message.content.root[0]); + let m = ensure_message(message.content.root[0], message.rowid); if (!m.child_messages) { m.child_messages = []; } @@ -191,16 +192,16 @@ class TfNewsElement extends LitElement { ); let unread_rowid = -1; for (let message of final_messages) { - if (message.rowid < this.channel_unread) { + if (message.rowid >= this.channel_unread) { unread_rowid = message.rowid; - break; } } return html`
${final_messages.map( (x) => - html` ${x.rowid == unread_rowid && x != final_messages[0] + html` + ${x.rowid == unread_rowid && x != final_messages[0] ? html`