Fix: remove duplicates in the TL caused by rendering reply parents
parent
29020fbcee
commit
1b5c347667
|
@ -30,6 +30,7 @@ export class FeedItemModel {
|
||||||
_isThreadParent: boolean = false
|
_isThreadParent: boolean = false
|
||||||
_isThreadChildElided: boolean = false
|
_isThreadChildElided: boolean = false
|
||||||
_isThreadChild: boolean = false
|
_isThreadChild: boolean = false
|
||||||
|
_hideParent: boolean = true // used to avoid dup post rendering while showing some parents
|
||||||
|
|
||||||
// data
|
// data
|
||||||
post: PostView
|
post: PostView
|
||||||
|
@ -463,6 +464,7 @@ export class FeedModel {
|
||||||
} else {
|
} else {
|
||||||
this.feed = this.feed.concat(toAppend)
|
this.feed = this.feed.concat(toAppend)
|
||||||
}
|
}
|
||||||
|
dedupParents(this.feed)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,6 +603,29 @@ function preprocessFeed(feed: FeedViewPost[]): FeedViewPostWithThreadMeta[] {
|
||||||
return reorg
|
return reorg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dedupParents(feed: FeedItemModel[]) {
|
||||||
|
// only show parents that aren't already in the feed
|
||||||
|
// NOTE if a parent post arrives in a followup loadmore, it'll show when we otherwise wish it wouldnt -prf
|
||||||
|
for (let i = 0; i < feed.length; i++) {
|
||||||
|
const item1 = feed[i]
|
||||||
|
if (!item1.replyParent || item1._isThreadChild) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
let hideParent = false
|
||||||
|
for (let j = 0; j < feed.length; j++) {
|
||||||
|
const item2 = feed[j]
|
||||||
|
if (
|
||||||
|
item1.replyParent.post.uri === item2.post.uri || // the post itself is there
|
||||||
|
(j < i && item1.replyParent.post.uri === item2.replyParent?.post.uri) // another reply already showed it
|
||||||
|
) {
|
||||||
|
hideParent = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item1._hideParent = hideParent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getSelfReplyUri(item: FeedViewPost): string | undefined {
|
function getSelfReplyUri(item: FeedViewPost): string | undefined {
|
||||||
return item.reply?.parent.author.did === item.post.author.did
|
return item.reply?.parent.author.did === item.post.author.did
|
||||||
? item.reply?.parent.uri
|
? item.reply?.parent.uri
|
||||||
|
|
|
@ -96,7 +96,8 @@ export const FeedItem = observer(function ({
|
||||||
return <View />
|
return <View />
|
||||||
}
|
}
|
||||||
|
|
||||||
const isChild = item._isThreadChild || (!item.reason && item.reply)
|
const isChild =
|
||||||
|
item._isThreadChild || (!item.reason && !item._hideParent && item.reply)
|
||||||
const isSmallTop = isChild && item._isThreadChild
|
const isSmallTop = isChild && item._isThreadChild
|
||||||
const isNoTop = isChild && !item._isThreadChild
|
const isNoTop = isChild && !item._isThreadChild
|
||||||
const outerStyles = [
|
const outerStyles = [
|
||||||
|
|
Loading…
Reference in New Issue