Revert to filerting out orphan threads
This commit is contained in:
@@ -12,13 +12,6 @@ import {ReasonFeedSource} from './feed/types'
|
|||||||
|
|
||||||
type FeedViewPost = AppBskyFeedDefs.FeedViewPost
|
type FeedViewPost = AppBskyFeedDefs.FeedViewPost
|
||||||
|
|
||||||
type ReplyRefMap = Map<
|
|
||||||
string,
|
|
||||||
| AppBskyFeedDefs.PostView
|
|
||||||
| AppBskyFeedDefs.BlockedPost
|
|
||||||
| AppBskyFeedDefs.NotFoundPost
|
|
||||||
>
|
|
||||||
|
|
||||||
export type FeedTunerFn = (
|
export type FeedTunerFn = (
|
||||||
tuner: FeedTuner,
|
tuner: FeedTuner,
|
||||||
slices: FeedViewPostsSlice[],
|
slices: FeedViewPostsSlice[],
|
||||||
@@ -48,7 +41,7 @@ export class FeedViewPostsSlice {
|
|||||||
isOrphan: boolean
|
isOrphan: boolean
|
||||||
rootUri: string
|
rootUri: string
|
||||||
|
|
||||||
constructor(feedPost: FeedViewPost, replyRefMap: ReplyRefMap) {
|
constructor(feedPost: FeedViewPost) {
|
||||||
const {post, reply, reason} = feedPost
|
const {post, reply, reason} = feedPost
|
||||||
this.items = []
|
this.items = []
|
||||||
this.isIncompleteThread = false
|
this.isIncompleteThread = false
|
||||||
@@ -96,9 +89,7 @@ export class FeedViewPostsSlice {
|
|||||||
this.isOrphan = true
|
this.isOrphan = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const grandparent = parent?.record?.reply?.parent?.uri
|
const grandparent = reply?.grandparent
|
||||||
? replyRefMap.get(parent.record.reply.parent.uri)
|
|
||||||
: undefined
|
|
||||||
const grandparentAuthor = reply.grandparentAuthor
|
const grandparentAuthor = reply.grandparentAuthor
|
||||||
const isGrandparentBlocked = Boolean(
|
const isGrandparentBlocked = Boolean(
|
||||||
grandparent && AppBskyFeedDefs.isBlockedPost(grandparent),
|
grandparent && AppBskyFeedDefs.isBlockedPost(grandparent),
|
||||||
@@ -111,7 +102,8 @@ export class FeedViewPostsSlice {
|
|||||||
})
|
})
|
||||||
if (isGrandparentBlocked) {
|
if (isGrandparentBlocked) {
|
||||||
this.isOrphan = true
|
this.isOrphan = true
|
||||||
return
|
// Keep going, it might still have a root, and we need this for thread
|
||||||
|
// de-deduping
|
||||||
}
|
}
|
||||||
const root = reply.root
|
const root = reply.root
|
||||||
if (
|
if (
|
||||||
@@ -213,22 +205,8 @@ export class FeedTuner {
|
|||||||
dryRun: false,
|
dryRun: false,
|
||||||
},
|
},
|
||||||
): FeedViewPostsSlice[] {
|
): 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
|
let slices: FeedViewPostsSlice[] = feed
|
||||||
.map(item => new FeedViewPostsSlice(item, replyRefMap))
|
.map(item => new FeedViewPostsSlice(item))
|
||||||
.filter(s => s.items.length > 0 || s.isFallbackMarker)
|
.filter(s => s.items.length > 0 || s.isFallbackMarker)
|
||||||
|
|
||||||
// run the custom tuners
|
// run the custom tuners
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export function useFeedTuners(feedDesc: FeedDescriptor) {
|
|||||||
return feedTuners
|
return feedTuners
|
||||||
}
|
}
|
||||||
if (feedDesc === 'following') {
|
if (feedDesc === 'following') {
|
||||||
const feedTuners = []
|
const feedTuners = [FeedTuner.removeOrphans]
|
||||||
|
|
||||||
if (preferences?.feedViewPrefs.hideReposts) {
|
if (preferences?.feedViewPrefs.hideReposts) {
|
||||||
feedTuners.push(FeedTuner.removeReposts)
|
feedTuners.push(FeedTuner.removeReposts)
|
||||||
|
|||||||
Reference in New Issue
Block a user