diff options
Diffstat (limited to 'ui/src/components/post.tsx')
-rw-r--r-- | ui/src/components/post.tsx | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index a8a94f0b..b0faf850 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -45,6 +45,7 @@ interface PostState { community: Community; moderators: Array<CommunityUser>; admins: Array<UserView>; + online: number; scrolled?: boolean; scrolled_comment_id?: number; loading: boolean; @@ -60,6 +61,7 @@ export class Post extends Component<any, PostState> { community: null, moderators: [], admins: [], + online: null, scrolled: false, loading: true, crossPosts: [], @@ -276,6 +278,7 @@ export class Post extends Component<any, PostState> { community={this.state.community} moderators={this.state.moderators} admins={this.state.admins} + online={this.state.online} /> </div> ); @@ -374,6 +377,7 @@ export class Post extends Component<any, PostState> { this.state.community = data.community; this.state.moderators = data.moderators; this.state.admins = data.admins; + this.state.online = data.online; this.state.loading = false; document.title = `${this.state.post.name} - ${WebSocketService.Instance.site.name}`; @@ -392,8 +396,12 @@ export class Post extends Component<any, PostState> { this.setState(this.state); } else if (res.op == UserOperation.CreateComment) { let data = res.data as CommentResponse; - this.state.comments.unshift(data.comment); - this.setState(this.state); + + // Necessary since it might be a user reply + if (data.recipient_ids.length == 0) { + this.state.comments.unshift(data.comment); + this.setState(this.state); + } } else if (res.op == UserOperation.EditComment) { let data = res.data as CommentResponse; let found = this.state.comments.find(c => c.id == data.comment.id); @@ -428,10 +436,15 @@ export class Post extends Component<any, PostState> { this.setState(this.state); } else if (res.op == UserOperation.CreatePostLike) { let data = res.data as PostResponse; - this.state.post.my_vote = data.post.my_vote; this.state.post.score = data.post.score; this.state.post.upvotes = data.post.upvotes; this.state.post.downvotes = data.post.downvotes; + if (data.post.my_vote !== null) { + this.state.post.my_vote = data.post.my_vote; + this.state.post.upvoteLoading = false; + this.state.post.downvoteLoading = false; + } + this.setState(this.state); } else if (res.op == UserOperation.EditPost) { let data = res.data as PostResponse; |