fix replies to parents the user doesn't follow

This commit is contained in:
Jonathan Staab 2023-08-04 09:57:45 -07:00
parent 5867fbf322
commit 3fac46e2e2
2 changed files with 5 additions and 7 deletions

View File

@ -114,14 +114,14 @@ export class ContextLoader {
const repliesByParentId = {} as Record<string, Event[]> const repliesByParentId = {} as Record<string, Event[]>
for (const event of this.data.get()) { for (const event of this.data.get()) {
const parentId = findReplyId(event)
if (contextById[event.id]) { if (contextById[event.id]) {
continue continue
} }
contextById[event.id] = event contextById[event.id] = event
const parentId = findReplyId(event)
if (event.kind === 9735) { if (event.kind === 9735) {
pushToKey(zapsByParentId, parentId, event) pushToKey(zapsByParentId, parentId, event)
} else if (event.kind === 7) { } else if (event.kind === 7) {

View File

@ -107,10 +107,8 @@ export class FeedLoader {
addToFeed = (notes: Event[]) => { addToFeed = (notes: Event[]) => {
this.feed.update($feed => { this.feed.update($feed => {
// Avoid showing the same note twice, even if it's once as a parent and once as a child // Avoid showing the same note twice, even if it's once as a parent and once as a child
const feedIds = pluck("id", $feed) const feedIds = new Set(pluck("id", $feed))
const feedParentIds = $feed.map(findReplyId).filter(identity) const feedParentIds = new Set($feed.map(findReplyId).filter(identity))
const noteParentIds = notes.map(findReplyId).filter(identity)
const ids = new Set([...feedIds, ...feedParentIds, ...noteParentIds])
return uniqBy( return uniqBy(
prop("id"), prop("id"),
@ -118,7 +116,7 @@ export class FeedLoader {
this.context.applyContext( this.context.applyContext(
sortBy( sortBy(
e => -e.created_at, e => -e.created_at,
notes.filter(e => !ids.has(findReplyId(e))) notes.filter(e => !feedIds.has(findReplyId(e)) && !feedParentIds.has(e.id))
), ),
true true
) )