From 93c9ae86f209c553d77cf850911b060171901d02 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Mon, 5 Jul 2021 13:08:14 +0500 Subject: [PATCH] fixed local vote map duplication because of undefined post-id --- src/components/upvote/container/upvoteContainer.js | 4 ++-- src/redux/actions/postsAction.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/upvote/container/upvoteContainer.js b/src/components/upvote/container/upvoteContainer.js index 3f2fe55ef..fedc01d38 100644 --- a/src/components/upvote/container/upvoteContainer.js +++ b/src/components/upvote/container/upvoteContainer.js @@ -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, diff --git a/src/redux/actions/postsAction.ts b/src/redux/actions/postsAction.ts index 320b55519..9e24610ad 100644 --- a/src/redux/actions/postsAction.ts +++ b/src/redux/actions/postsAction.ts @@ -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, });