From ff2f70b1de84bece85a8e8e4f02b6b7e963b097e Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 12 Jul 2020 00:58:42 -0400 Subject: Moving recent comments into main view as a chat select. Fixes #943 --- ui/src/components/post.tsx | 184 +++++++++++++++++++++++++++------------------ 1 file changed, 110 insertions(+), 74 deletions(-) (limited to 'ui/src/components/post.tsx') diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index 5d76808e..3b0a8d4a 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -11,6 +11,7 @@ import { CommentForm as CommentFormI, CommentResponse, CommentSortType, + CommentViewType, CommunityUser, CommunityResponse, CommentNode as CommentNodeI, @@ -49,6 +50,7 @@ interface PostState { post: PostI; comments: Array; commentSort: CommentSortType; + commentViewType: CommentViewType; community: Community; moderators: Array; online: number; @@ -65,6 +67,7 @@ export class Post extends Component { post: null, comments: [], commentSort: CommentSortType.Hot, + commentViewType: CommentViewType.Tree, community: null, moderators: [], online: null, @@ -208,12 +211,12 @@ export class Post extends Component { disabled={this.state.post.locked} /> {this.state.comments.length > 0 && this.sortRadios()} - {this.commentsTree()} - -
- {this.state.comments.length > 0 && this.newComments()} - {this.sidebar()} + {this.state.commentViewType == CommentViewType.Tree && + this.commentsTree()} + {this.state.commentViewType == CommentViewType.Chat && + this.commentsFlat()}
+
{this.sidebar()}
)} @@ -222,79 +225,107 @@ export class Post extends Component { sortRadios() { return ( -
- - - - -
+ <> +
+ + + + +
+
+ + +
+ ); } - newComments() { + commentsFlat() { return ( -
-
-
{i18n.t('recent_comments')}
- -
+
+
); } @@ -318,6 +349,11 @@ export class Post extends Component { i.setState(i.state); } + handleCommentViewTypeChange(i: Post, event: any) { + i.state.commentViewType = Number(event.target.value); + i.setState(i.state); + } + buildCommentsTree(): Array { let map = new Map(); for (let comment of this.state.comments) { -- cgit v1.2.3