Fix duplicates showing up in the feed due to reply parents

zio/stable
Paul Frazee 2023-03-21 13:20:35 -05:00
parent 92d9267805
commit 35fae5ab25
1 changed files with 9 additions and 1 deletions

View File

@ -116,9 +116,14 @@ export class FeedTuner {
} }
// remove any items already "seen" // remove any items already "seen"
const soonToBeSeenUris: Set<string> = new Set()
for (let i = slices.length - 1; i >= 0; i--) { for (let i = slices.length - 1; i >= 0; i--) {
if (this.seenUris.has(slices[i].uri)) { if (this.seenUris.has(slices[i].uri)) {
slices.splice(i, 1) slices.splice(i, 1)
} else {
for (const item of slices[i].items) {
soonToBeSeenUris.add(item.post.uri)
}
} }
} }
@ -128,9 +133,12 @@ export class FeedTuner {
!slice.isThread && !slice.isThread &&
!slice.items[0].reason && !slice.items[0].reason &&
slice.items[0].reply?.parent && slice.items[0].reply?.parent &&
!this.seenUris.has(slice.items[0].reply?.parent.uri) !this.seenUris.has(slice.items[0].reply?.parent.uri) &&
!soonToBeSeenUris.has(slice.items[0].reply?.parent.uri)
) { ) {
const uri = slice.items[0].reply?.parent.uri
slice.flattenReplyParent() slice.flattenReplyParent()
soonToBeSeenUris.add(uri)
} }
} }