fixed local vote map duplication because of undefined post-id

This commit is contained in:
Nouman Tahir 2021-07-05 13:08:14 +05:00
parent 3befe48910
commit 93c9ae86f2
2 changed files with 12 additions and 3 deletions

View File

@ -72,7 +72,7 @@ const UpvoteContainer = (props) => {
};
const _handleLocalVote = () => {
const postId = get(content, 'post_id');
const postId = `${content.author || ''}-${content.permlink || ''}`;
const postFetchedAt = get(content, 'post_fetched_at', 0);
const localVote = localVoteMap[postId] || null;
if (localVote) {
@ -113,7 +113,7 @@ const UpvoteContainer = (props) => {
setTotalPayout(totalPayout + amountNum);
//update redux
const postId = get(content, 'post_id');
const postId = `${content.author || ''}-${content.permlink || ''}`;
const vote = {
votedAt: new Date().getTime(),
amount: amountNum,

View File

@ -29,13 +29,22 @@ export const setOtherPosts = (posts, scrollPosition = 0) => ({
},
type: SET_OTHER_POSTS,
});
export const updateLocalVoteMap = (postId, localVote) => ({
export const updateLocalVoteMap = (postId:string, localVote:{
votedAt: number,
amount: number,
isDownvote: boolean,
incrementStep: number
}) => ({
payload: {
postId,
localVote,
},
type: UPDATE_LOCAL_VOTE_MAP,
});
export const resetLocalVoteMap = () => ({
type: RESET_LOCAL_VOTE_MAP,
});