From 65fcaafab7b5082fa894be2a1e7b5bc9506fee6c Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sun, 2 Jul 2023 15:07:24 -0400 Subject: [PATCH] fix: Fix vote buttons not showing spinners while registering vote #1761 --- src/shared/components/common/vote-buttons.tsx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/shared/components/common/vote-buttons.tsx b/src/shared/components/common/vote-buttons.tsx index 69df94b..2595bb6 100644 --- a/src/shared/components/common/vote-buttons.tsx +++ b/src/shared/components/common/vote-buttons.tsx @@ -64,8 +64,6 @@ const handleUpvote = (i: VoteButtons) => { auth: myAuthRequired(), }); } - - i.setState({ upvoteLoading: false }); }; const handleDownvote = (i: VoteButtons) => { @@ -86,7 +84,6 @@ const handleDownvote = (i: VoteButtons) => { auth: myAuthRequired(), }); } - i.setState({ downvoteLoading: false }); }; export class VoteButtonsCompact extends Component< @@ -102,6 +99,15 @@ export class VoteButtonsCompact extends Component< super(props, context); } + componentWillReceiveProps(nextProps: VoteButtonsProps) { + if (this.props !== nextProps) { + this.setState({ + upvoteLoading: false, + downvoteLoading: false, + }); + } + } + render() { return ( <> @@ -172,6 +178,15 @@ export class VoteButtons extends Component { super(props, context); } + componentWillReceiveProps(nextProps: VoteButtonsProps) { + if (this.props !== nextProps) { + this.setState({ + upvoteLoading: false, + downvoteLoading: false, + }); + } + } + render() { return (
-- 2.44.1