mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-01 17:56:48 +03:00
Merge pull request #2152 from ecency/nt/comment-upvote
Improved cache Vote Increment handlers
This commit is contained in:
commit
55289dc10d
@ -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}
|
||||
/>
|
||||
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user