anbot

9d3e7fc / anbot.mjs

View file at this commit

diff --git a/anbot.mjs b/anbot.mjs
index 2f9df70..33e2021 100644
--- a/anbot.mjs
+++ b/anbot.mjs
@@ -138,8 +138,20 @@ async function servePoll(root, response, query) {
     return
   }
   try {
-    const [records, posts] = await Promise.all([listVerifiedRecords(root), listLocalPostRecords(root)])
-    const verified = [...new Map([...records, ...posts].map(entry => [entry.record.id, entry])).values()]
+    const [records, posts, selection] = await Promise.all([
+      listVerifiedRecords(root), listLocalPostRecords(root), createFsStore(root).getSelection()
+    ])
+    const byId = new Map(records.map(entry => [entry.record.id, entry]))
+    const visible = new Set([selection.repoId])
+    for (let id = selection.updateId; id != null;) {
+      requireThat(!visible.has(id) && byId.has(id), 'Incomplete selected update history')
+      visible.add(id)
+      const { previous, previousUpdate } = parseJson(byId.get(id).record.content)
+      id = previous ?? previousUpdate
+    }
+    const shared = records.filter(({ record }) =>
+      visible.has(record.id) || parseJson(record.content)?.type === 'post')
+    const verified = [...new Map([...shared, ...posts].map(entry => [entry.record.id, entry])).values()]
     verified.sort(compareRecords)
     const after = cursor
       ? verified.filter(({ record, timestamp }) =>

Git ยท Social feed