Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comments bugs #2384

Merged
merged 12 commits into from May 11, 2021
Merged

Conversation

tiagoalvesdulce
Copy link
Member

@tiagoalvesdulce tiagoalvesdulce commented May 8, 2021

Closes #2374
Closes #2375

This was a tough one to debug...

Solution description

Comment sorting (#2374)
Comment sorting was wrong because resultvotes wasn't being updated properly in the comments reducer. I moved it from there to the Container level because we don't need to store it at all since we can easily calculate it using up and downvotes.

Wrong vote color (Scenario 1 on #2375)
The useComments hook was passing actionData.data as the vote option to the Likes component but the right property is vote. Changing it to actionData.vote fixed the issue.

Wrong vote count (Scenario 2 on #2375)
The RECEIVE_LIKED_COMMENTS action on comments reducer was using a wrong property name to store commentsLikes.

Unnecessary component updates
While working on this issue I noticed some unnecessary updates when hovering the vote button. See:
multipleupdatecomment

This was happening because we were using a javascript approach with the useHover hook from pi-ui. In this specific case I could come up with a CSS-only solution to deal with hover and prevent unnecessary component updates.

hovercommentsimproved

Wrong behavior on error (tested max number of vote changes)
I would like a review from @victorgcramos on this one because he was the last one to touch this piece of code. I don't get why we need RESET_SYNC_LIKE_COMMENT and why we are dispatching it on error. This was leading to some weird errors when hitting the max number of votes error.

Improve code comments
The function that was calculating upvotes and downvotes based on the user previous vote had one edge case wrong and was very hard to understand/debug. I refactored it and add some comments.

Comment vote UX (#2375 (comment))
Removed the not-allowed symbol during api loading and added a 500ms debounce to the voting functions so the user can't spam the button.

@victorgcramos
Copy link
Member

SYNC_LIKE actions can be removed. I think they are pointless.

Copy link
Member

@amass01 amass01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice job!

Copy link
Member

@lukebp lukebp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@tiagoalvesdulce tiagoalvesdulce merged commit ee224fc into decred:master May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Own comment votes displayed incorrectly Comment sorting bug
4 participants