Merge pull request #2152 from ecency/nt/comment-upvote

Improved cache Vote Increment handlers
This commit is contained in:
Feruz M 2022-01-19 21:36:06 +02:00 committed by GitHub
commit 55289dc10d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 8 deletions

View File

@ -49,6 +49,7 @@ const CommentView = ({
const [_isShowSubComments, setIsShowSubComments] = useState(isShowSubComments || false);
const [isPressedShowButton, setIsPressedShowButton] = useState(false);
const [activeVotes, setActiveVotes] = useState([]);
const [cacheVoteIcrement, setCacheVoteIcrement] = useState(0);
@ -68,6 +69,11 @@ const CommentView = ({
};
const _handleCacheVoteIncrement = () => {
//fake increment vote using based on local change
setCacheVoteIcrement(1);
};
const _renderReadMoreButton = () => (
<TextWithIcon
@ -144,7 +150,12 @@ const CommentView = ({
const _renderActionPanel = () => {
return (
<>
<Upvote activeVotes={activeVotes} isShowPayoutValue content={comment} />
<Upvote
activeVotes={activeVotes}
isShowPayoutValue
content={comment}
handleCacheVoteIncrement={_handleCacheVoteIncrement}
/>
<TextWithIcon
iconName="heart-outline"
iconSize={20}
@ -156,7 +167,7 @@ const CommentView = ({
activeVotes.length > 0 &&
handleOnVotersPress(activeVotes, comment)
}
text={activeVotes.length}
text={activeVotes.length + cacheVoteIcrement}
textStyle={styles.voteCountText}
/>

View File

@ -71,7 +71,7 @@ const PostCardView = ({
}
};
const _handleIncrementVoteCount = () => {
const _handleCacheVoteIncrement = () => {
//fake increment vote using based on local change
setCacheVoteIcrement(1);
};
@ -172,7 +172,7 @@ const PostCardView = ({
activeVotes={activeVotes}
isShowPayoutValue
content={content}
incrementVoteCount={_handleIncrementVoteCount}
handleCacheVoteIncrement={_handleCacheVoteIncrement}
/>
<TouchableOpacity style={styles.commentButton} onPress={_handleOnVotersPress}>
<TextWithIcon

View File

@ -92,7 +92,7 @@ const PostDisplayView = ({
}
};
const _handleIncrementActiveVotesCount = () => {
const _handleCacheVoteIncrement = () => {
setCacheVoteIcrement(1);
};
@ -105,7 +105,7 @@ const PostDisplayView = ({
activeVotes={activeVotes}
isShowPayoutValue
content={post}
incrementVoteCount={_handleIncrementActiveVotesCount}
handleCacheVoteIncrement={_handleCacheVoteIncrement}
/>
<TextWithIcon
iconName="heart-outline"

View File

@ -35,7 +35,7 @@ const UpvoteContainer = (props) => {
globalProps,
dispatch,
activeVotes = [],
incrementVoteCount,
handleCacheVoteIncrement,
fetchPost,
} = props;
@ -100,7 +100,7 @@ const UpvoteContainer = (props) => {
setTotalPayout(get(content, 'total_payout') + amount);
if (incrementStep > 0) {
incrementVoteCount();
handleCacheVoteIncrement();
}
setIsDownVoted(isDownvote ? true : false);