]> Untitled Git - lemmy.git/commitdiff
New nsfw posts.
authorDessalines <tyhou13@gmx.com>
Thu, 27 Feb 2020 21:24:27 +0000 (16:24 -0500)
committerDessalines <tyhou13@gmx.com>
Thu, 27 Feb 2020 21:24:27 +0000 (16:24 -0500)
ui/src/components/main.tsx
ui/src/components/post-listing.tsx

index 87a2fb66b764867b6ee8e7d84a32af6b6c4f890f..81612009619611ef205fe9f2630485bfc6a313a4 100644 (file)
@@ -626,10 +626,20 @@ export class Main extends Component<any, MainState> {
           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);
index 8dbe1f48fe37a88bbe0d916fc7aa618b0f70c680..3e6e17eb30c96c141bcd8dcef0c48b469ab87e98 100644 (file)
@@ -846,7 +846,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
     } else {
       this.state.thumbnail = null;
     }
-    this.setState(this.state);
   }
 
   handlePostLike(i: PostListing) {