Revert to filerting out orphan threads

This commit is contained in:
Eric Bailey
2024-08-16 16:17:39 -05:00
parent 10cf2972a3
commit 18fbe71b10
2 changed files with 6 additions and 28 deletions
+5 -27
View File
@@ -12,13 +12,6 @@ import {ReasonFeedSource} from './feed/types'
type FeedViewPost = AppBskyFeedDefs.FeedViewPost
type ReplyRefMap = Map<
string,
| AppBskyFeedDefs.PostView
| AppBskyFeedDefs.BlockedPost
| AppBskyFeedDefs.NotFoundPost
>
export type FeedTunerFn = (
tuner: FeedTuner,
slices: FeedViewPostsSlice[],
@@ -48,7 +41,7 @@ export class FeedViewPostsSlice {
isOrphan: boolean
rootUri: string
constructor(feedPost: FeedViewPost, replyRefMap: ReplyRefMap) {
constructor(feedPost: FeedViewPost) {
const {post, reply, reason} = feedPost
this.items = []
this.isIncompleteThread = false
@@ -96,9 +89,7 @@ export class FeedViewPostsSlice {
this.isOrphan = true
return
}
const grandparent = parent?.record?.reply?.parent?.uri
? replyRefMap.get(parent.record.reply.parent.uri)
: undefined
const grandparent = reply?.grandparent
const grandparentAuthor = reply.grandparentAuthor
const isGrandparentBlocked = Boolean(
grandparent && AppBskyFeedDefs.isBlockedPost(grandparent),
@@ -111,7 +102,8 @@ export class FeedViewPostsSlice {
})
if (isGrandparentBlocked) {
this.isOrphan = true
return
// Keep going, it might still have a root, and we need this for thread
// de-deduping
}
const root = reply.root
if (
@@ -213,22 +205,8 @@ export class FeedTuner {
dryRun: false,
},
): FeedViewPostsSlice[] {
const replyRefMap: ReplyRefMap = new Map()
for (const item of feed) {
for (const ancestor of [item.reply?.parent, item.reply?.root]) {
// trust server for blocked and not found reply parent/root refs
if (
AppBskyFeedDefs.isPostView(ancestor) ||
AppBskyFeedDefs.isBlockedPost(ancestor) ||
AppBskyFeedDefs.isNotFoundPost(ancestor)
) {
replyRefMap.set(ancestor.uri, ancestor)
}
}
}
let slices: FeedViewPostsSlice[] = feed
.map(item => new FeedViewPostsSlice(item, replyRefMap))
.map(item => new FeedViewPostsSlice(item))
.filter(s => s.items.length > 0 || s.isFallbackMarker)
// run the custom tuners
+1 -1
View File
@@ -46,7 +46,7 @@ export function useFeedTuners(feedDesc: FeedDescriptor) {
return feedTuners
}
if (feedDesc === 'following') {
const feedTuners = []
const feedTuners = [FeedTuner.removeOrphans]
if (preferences?.feedViewPrefs.hideReposts) {
feedTuners.push(FeedTuner.removeReposts)