summaryrefslogtreecommitdiffstats
path: root/ui/src/components/post.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2019-04-15 16:12:06 -0700
committerDessalines <tyhou13@gmx.com>2019-04-15 16:12:06 -0700
commite94885eb97b3240ed9cec7f97d0f405b2819e922 (patch)
treeb407f0b6ed9be27682e3767271e34933c947cb2a /ui/src/components/post.tsx
parent8590a612f633fe6ba8f8b18379a8a822a3b3019b (diff)
Commiting before I lose everything. I'll do this properly in a merge
Diffstat (limited to 'ui/src/components/post.tsx')
-rw-r--r--ui/src/components/post.tsx22
1 files changed, 18 insertions, 4 deletions
diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx
index 5ca3f770..c65f463d 100644
--- a/ui/src/components/post.tsx
+++ b/ui/src/components/post.tsx
@@ -1,7 +1,7 @@
import { Component, linkEvent } from 'inferno';
import { Subscription } from "rxjs";
import { retryWhen, delay, take } from 'rxjs/operators';
-import { UserOperation, Community, Post as PostI, GetPostResponse, PostResponse, Comment, CommentResponse, CommentSortType, CreatePostLikeResponse, CommunityUser, CommunityResponse, CommentNode as CommentNodeI } from '../interfaces';
+import { UserOperation, Community, Post as PostI, GetPostResponse, PostResponse, Comment, CommentResponse, CommentSortType, CreatePostLikeResponse, CommunityUser, CommunityResponse, CommentNode as CommentNodeI, BanFromCommunityResponse, AddModToCommunityResponse } from '../interfaces';
import { WebSocketService } from '../services';
import { msgOp, hotRank } from '../utils';
import { PostListing } from './post-listing';
@@ -82,7 +82,7 @@ export class Post extends Component<any, PostState> {
<div class="col-12 col-sm-8 col-lg-7 mb-3">
<PostListing post={this.state.post} showBody showCommunity editable />
<div className="mb-2" />
- <CommentForm postId={this.state.post.id} />
+ <CommentForm postId={this.state.post.id} disabled={this.state.post.locked} />
{this.sortRadios()}
{this.commentsTree()}
</div>
@@ -125,7 +125,7 @@ export class Post extends Component<any, PostState> {
<div class="sticky-top">
<h4>New Comments</h4>
{this.state.comments.map(comment =>
- <CommentNodes nodes={[{comment: comment}]} noIndent />
+ <CommentNodes nodes={[{comment: comment}]} noIndent locked={this.state.post.locked} moderators={this.state.moderators} />
)}
</div>
)
@@ -188,7 +188,7 @@ export class Post extends Component<any, PostState> {
let nodes = this.buildCommentsTree();
return (
<div className="">
- <CommentNodes nodes={nodes} />
+ <CommentNodes nodes={nodes} locked={this.state.post.locked} moderators={this.state.moderators} />
</div>
);
}
@@ -216,6 +216,11 @@ export class Post extends Component<any, PostState> {
let found = this.state.comments.find(c => c.id == res.comment.id);
found.content = res.comment.content;
found.updated = res.comment.updated;
+ found.removed = res.comment.removed;
+ found.upvotes = res.comment.upvotes;
+ found.downvotes = res.comment.downvotes;
+ found.score = res.comment.score;
+
this.setState(this.state);
}
else if (op == UserOperation.CreateCommentLike) {
@@ -249,6 +254,15 @@ export class Post extends Component<any, PostState> {
this.state.community.subscribed = res.community.subscribed;
this.state.community.number_of_subscribers = res.community.number_of_subscribers;
this.setState(this.state);
+ } else if (op == UserOperation.BanFromCommunity) {
+ let res: BanFromCommunityResponse = msg;
+ this.state.comments.filter(c => c.creator_id == res.user.id)
+ .forEach(c => c.banned = res.banned);
+ this.setState(this.state);
+ } else if (op == UserOperation.AddModToCommunity) {
+ let res: AddModToCommunityResponse = msg;
+ this.state.moderators = res.moderators;
+ this.setState(this.state);
}
}