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
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ export const defaultSettings: Settings = {
|
||||
comments: env.PUBLIC_DEFAULT_COMMENT_SORT ?? ('Hot' as any),
|
||||
},
|
||||
hidePosts: {
|
||||
deleted: toBool(env.PUBLIC_HIDE_DELETED) ?? true,
|
||||
deleted: toBool(env.PUBLIC_HIDE_DELETED) ?? false,
|
||||
removed: toBool(env.PUBLIC_HIDE_REMOVED) ?? false,
|
||||
},
|
||||
expandSidebar: toBool(env.PUBLIC_EXPAND_SIDEBAR) ?? true,
|
||||
|
||||
@@ -302,7 +302,15 @@
|
||||
{/if}
|
||||
<Comments
|
||||
post={post.post_view.post}
|
||||
nodes={buildCommentsTree(data.comments.comments)}
|
||||
nodes={buildCommentsTree(
|
||||
data.comments.comments,
|
||||
undefined,
|
||||
(c) =>
|
||||
!(
|
||||
($userSettings.hidePosts.deleted && c.comment.deleted) ||
|
||||
($userSettings.hidePosts.removed && c.comment.removed)
|
||||
)
|
||||
)}
|
||||
isParent={true}
|
||||
/>
|
||||
{#if post.post_view.counts.comments > 5}
|
||||
|
||||
@@ -191,9 +191,9 @@
|
||||
description="Blur images and remove post bodies of NSFW content."
|
||||
/>
|
||||
<Setting>
|
||||
<span slot="title">Hide Posts</span>
|
||||
<span slot="title">Hide Submissions</span>
|
||||
<span slot="description">
|
||||
<p>Hide certain types of posts.</p>
|
||||
<p>Hide certain types of submissions.</p>
|
||||
<p>
|
||||
Looking to hide read posts? That was moved to your <Link
|
||||
href="/profile/settings"
|
||||
|
||||
Reference in new issue
Block a user