From f31c7816938808e3bab133d1cb7d842fef2e4c8e 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 4d216f97..2c15b6c8 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 && (