diff options
author | Dessalines <tyhou13@gmx.com> | 2019-04-03 13:59:37 -0700 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2019-04-03 13:59:37 -0700 |
commit | e690d6c470c6330b31e39448fe9e566a30860b14 (patch) | |
tree | 37f7bf5629f1a5fd01442df2bd3a35c705b40f54 /ui/src/components/post.tsx | |
parent | c7864643812645ecfb560154bcb1e758555126de (diff) |
Adding post editing.
- Adding post editing. Fixes #23
- Making SQL versions of comment and post fetching. Fixes #21
- Starting to add forum categories. #17
Diffstat (limited to 'ui/src/components/post.tsx')
-rw-r--r-- | ui/src/components/post.tsx | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index 914eebb5..68ba9634 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -1,7 +1,8 @@ import { Component, linkEvent } from 'inferno'; +import { Link } from 'inferno-router'; import { Subscription } from "rxjs"; import { retryWhen, delay, take } from 'rxjs/operators'; -import { UserOperation, Community, Post as PostI, PostResponse, Comment, CommentForm as CommentFormI, CommentResponse, CommentLikeForm, CreateCommentLikeResponse, CommentSortType, CreatePostLikeResponse } from '../interfaces'; +import { UserOperation, Community, Post as PostI, GetPostResponse, PostResponse, Comment, CommentForm as CommentFormI, CommentResponse, CommentLikeForm, CreateCommentLikeResponse, CommentSortType, CreatePostLikeResponse } from '../interfaces'; import { WebSocketService, UserService } from '../services'; import { msgOp, hotRank,mdToHtml } from '../utils'; import { MomentTime } from './moment-time'; @@ -60,7 +61,7 @@ export class Post extends Component<any, State> { {this.state.post && <div class="row"> <div class="col-12 col-sm-8 col-lg-7 mb-3"> - <PostListing post={this.state.post} showBody showCommunity /> + <PostListing post={this.state.post} showBody showCommunity editable /> <div className="mb-2" /> <CommentForm postId={this.state.post.id} /> {this.sortRadios()} @@ -181,7 +182,7 @@ export class Post extends Component<any, State> { alert(msg.error); return; } else if (op == UserOperation.GetPost) { - let res: PostResponse = msg; + let res: GetPostResponse = msg; this.state.post = res.post; this.state.comments = res.comments; this.setState(this.state); @@ -212,6 +213,10 @@ export class Post extends Component<any, State> { this.state.post.upvotes = res.post.upvotes; this.state.post.downvotes = res.post.downvotes; this.setState(this.state); + } else if (op == UserOperation.EditPost) { + let res: PostResponse = msg; + this.state.post = res.post; + this.setState(this.state); } } @@ -281,7 +286,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> { <div className="details ml-4"> <ul class="list-inline mb-0 text-muted small"> <li className="list-inline-item"> - <a href={node.comment.attributed_to}>{node.comment.attributed_to}</a> + <Link to={`/user/${node.comment.creator_id}`}>{node.comment.creator_name}</Link> </li> <li className="list-inline-item"> <span>( @@ -327,7 +332,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> { } private get myComment(): boolean { - return this.props.node.comment.attributed_to == UserService.Instance.fediUserId; + return UserService.Instance.loggedIn && this.props.node.comment.creator_id == UserService.Instance.user.id; } handleReplyClick(i: CommentNode, event) { |