From 3d649756eca377d20de0c47c9cc50d0d76d4b4ba Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 27 Feb 2020 16:24:27 -0500 Subject: [PATCH] New nsfw posts. --- ui/src/components/main.tsx | 16 +++++++++++++--- ui/src/components/post-listing.tsx | 1 - 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 87a2fb66..81612009 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -626,10 +626,20 @@ export class Main extends Component { this.state.posts.unshift(data.post); } } else { - this.state.posts.unshift(data.post); - } + // NSFW posts + let nsfw = data.post.nsfw || data.post.community_nsfw; - this.setState(this.state); + // Don't push the post if its nsfw, and don't have that setting on + if ( + !nsfw || + (nsfw && + UserService.Instance.user && + UserService.Instance.user.show_nsfw) + ) { + this.state.posts.unshift(data.post); + this.setState(this.state); + } + } } else if (res.op == UserOperation.EditPost) { let data = res.data as PostResponse; editPostFindRes(data, this.state.posts); diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index 8dbe1f48..3e6e17eb 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -846,7 +846,6 @@ export class PostListing extends Component { } else { this.state.thumbnail = null; } - this.setState(this.state); } handlePostLike(i: PostListing) { -- 2.44.1