From 3f4cce99ed01c6b3a686c6a7664bfb046e572267 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 13 Jan 2020 22:57:32 -0500 Subject: [PATCH] Add fast comment and post voting. (Doesn't wait for server return) - Fixes #416 --- ui/src/components/comment-node.tsx | 37 +++++++++++++++++++++------ ui/src/components/post-listing.tsx | 40 +++++++++++++++++++++++++----- 2 files changed, 64 insertions(+), 13 deletions(-) diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx index 4d216f971..2c15b6c8f 100644 --- a/ui/src/components/comment-node.tsx +++ b/ui/src/components/comment-node.tsx @@ -47,6 +47,8 @@ interface CommentNodeState { showConfirmAppointAsAdmin: boolean; collapsed: boolean; viewSource: boolean; + my_vote: number; + score: number; } interface CommentNodeProps { @@ -76,6 +78,8 @@ export class CommentNode extends Component { showConfirmTransferCommunity: false, showConfirmAppointAsMod: false, showConfirmAppointAsAdmin: false, + my_vote: this.props.node.comment.my_vote, + score: this.props.node.comment.score, }; constructor(props: any, context: any) { @@ -102,7 +106,7 @@ export class CommentNode extends Component { > -
- {node.comment.score} -
+
{this.state.score}
{WebSocketService.Instance.site.enable_downvotes && ( -
{post.score}
+
{this.state.score}
{WebSocketService.Instance.site.enable_downvotes && (