fix: close #279, deleted/removed posts are still shown
This commit is contained in:
1 parent
c7e3f4d56e
commit
df0cfbd932
5 files changed
+23
-7
No files matched your search
@@ -24,7 +24,8 @@ function getDepthFromComment(comment?: Comment): number | undefined {
|
||||
|
||||
export function buildCommentsTree(
|
||||
comments: CommentView[],
|
||||
baseDepth: number = 0
|
||||
baseDepth: number = 0,
|
||||
filter: (c: CommentView) => boolean = (c) => true
|
||||
): CommentNodeI[] {
|
||||
const map = new Map<number, CommentNodeI>()
|
||||
|
||||
@@ -38,7 +39,9 @@ export function buildCommentsTree(
|
||||
depth: depth,
|
||||
}
|
||||
min_depth = Math.min(min_depth, depth)
|
||||
map.set(comment_view.comment.id, { ...node })
|
||||
if (filter(comment_view)) {
|
||||
map.set(comment_view.comment.id, { ...node })
|
||||
}
|
||||
}
|
||||
|
||||
const tree: CommentNodeI[] = []
|
||||
|
||||
@@ -37,7 +37,12 @@
|
||||
const seenUrls = new Set<string>()
|
||||
|
||||
posts?.forEach((post) => {
|
||||
if (!post) return
|
||||
if (
|
||||
!post ||
|
||||
($userSettings.hidePosts.deleted && post.post.deleted) ||
|
||||
($userSettings.hidePosts.removed && post.post.removed)
|
||||
)
|
||||
return
|
||||
if (!post?.post?.url) {
|
||||
results.push(post)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user