Design comparison
Solution retrospective
This was a funny project. Probably some refactoring would not harm the project and will be a goal in the future. I have tried to make the project a bit like the comments section on youtube or similar websites. I have tried to practise a bit useReducer and context API. My feeling is that the code feels overcomplicated still but thats going to be a target in the next future to simplify it more. For now it feels good but some critical bugs will be fixed as soon as encountered :) Feel free to check it out. You can switch users on top to simulate another log in. If you leave the comments empty then you will send a random quote. Here I had already some funny conversations lol. Make sure to expand the comment if you want to check a reply. They are closed by default.
Community feedback
- @sambuka-aPosted about 1 year ago
thanks for the reply.Now I got it) Interesting approach. It would work even better with thumbs up/thumbs down. Honestly I didn't notice + and - active (blue) state, that is why it was a bit confusing. It is a really good idea to allow only one single reaction per active user. Don't have it in my solution. I did my reaction logic something similar to stackoverflow (negative score allowed + posts are sorted depending on score). But I should also really add user vote limitation per post/comment. Good luck in your WebDev journey
1 - @sambuka-aPosted about 1 year ago
Nice solution. Bzw, seems like post score logic doesn't work properly. In case you would like to play around fixing it
0@alexander-hergertPosted about 1 year ago@sambuka-a Hi thank you for inspecting this project. Can you give me more details? I just watched quickly over the scores but can't find any miss behaviour.
My intention was that each user can upvote or downvote a comment just once. So I used flags for upvoted or downvoted.
When user A upvotes a comment then it gets a point. If the user changes opinion it will drop by 2 points then. If never upvoted then directly just by 1 point. And so it behaves into the other direction for each User who votes.
So if you click on + then comment gets a point. If click again that point goes away since there are 3 states neutral, upvoted or downvoted. That also means that 4 users can only upvote a comment at max 4 points and downvote by max -4 points. This reminds me a lot on comments like on youtube if youtube would also calculate the downvotes in.
To reach this I have modified the given datastructure and added for each comment upvoted and downvoted array which is holding the unique usernames. The calculation is made by the contents of these arrays.
Also each flag is marked with the blue + or -. If you are neutral (not voted) its both gray.
These was no clear instruction to do this in the Readme thats why we have different solutions but i thought it would be more realistic that way. Please feel free to inspect it again or provide me more infos if that does not explain what you mean.
best Regards Alex
1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord