From ff2f70b1de84bece85a8e8e4f02b6b7e963b097e Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 12 Jul 2020 00:58:42 -0400 Subject: [PATCH] Moving recent comments into main view as a chat select. Fixes #943 --- ui/src/components/post.tsx | 184 ++++++++++++++++++++++--------------- ui/src/interfaces.ts | 5 + ui/translations/en.json | 1 + 3 files changed, 116 insertions(+), 74 deletions(-) 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) { diff --git a/ui/src/interfaces.ts b/ui/src/interfaces.ts index 774836a2..0bb09e2c 100644 --- a/ui/src/interfaces.ts +++ b/ui/src/interfaces.ts @@ -54,6 +54,11 @@ export enum CommentSortType { Old, } +export enum CommentViewType { + Tree, + Chat, +} + export enum ListingType { All, Subscribed, diff --git a/ui/translations/en.json b/ui/translations/en.json index cb4347f1..59dfa8b4 100644 --- a/ui/translations/en.json +++ b/ui/translations/en.json @@ -177,6 +177,7 @@ "community": "Community", "expand_here": "Expand here", "subscribe_to_communities": "Subscribe to some <1>communities.", + "tree": "Tree", "chat": "Chat", "recent_comments": "Recent Comments", "no_results": "No results.", -- 2.44.1