open-sauced / hot

πŸ•The site that recommends the hottest projects on GitHub.
https://hot.opensauced.pizza
MIT License
418 stars 145 forks source link

bug: downvoting a repo in myVotes list does not remove it from ui #416

Open NsdHSO opened 1 year ago

NsdHSO commented 1 year ago

Describe the bug

If you are in MyVotes section and you press on the upvote/voted list from My voted Repository

Steps to reproduce

  1. Go to the hot app
  2. MyVotes section
  3. Press upvote/voted
  4. look in My voted Repository it still remains behind

Affected services

hot.opensauced.pizza

Platforms

Desktop

Browsers

Chrome

Environment

Production

Additional context

No response

Code of Conduct

Contributing Docs

0-vortex commented 1 year ago

Do you mean after up or down voting, the repository remains in the list of voted repos? If so, you could adjust the title to something more relevant like "bug: downvoting a repo in myVotes list does not remove it from ui" πŸ•

NsdHSO commented 1 year ago

Do you mean after up or down voting, the repository remains in the list of voted repos? If so, you could adjust the title to something more relevant like "bug: downvoting a repo in myVotes list does not remove it from ui" πŸ•

yes, this is the issue, Tnx for your help.

0-vortex commented 1 year ago

@bdougie GFI?

bdougie commented 1 year ago

@bdougie GFI?

Not quite. This still needs more info and an attempt at a suggested solution. My guess is that the votes hooks need to refetch the votes when the button is clicked.

https://github.com/open-sauced/hot/blob/2d5bb0d9f694ea630030c56bc6c2985cf231e9b3/src/hooks/useVotedRepos.ts#L23

rajat4984 commented 1 year ago

Is this issue resolved?

Alexandre-Lustosa-Escossio commented 1 year ago

I'll try to .take this one

github-actions[bot] commented 1 year ago

Thanks for taking this on! If you have not already, join the conversation in our Discord

Alexandre-Lustosa-Escossio commented 1 year ago

Since I didn't have any pictures of the issue I tried going straight to the site and reproducing it. It turns out I'm not able to upvote any repository from any page. With further investigation, I found that the post call when I upvote/downvote a repo is returning 409 and apparently it's a problem in the database's schema so It might be nothing wrong with the code. image image Could someone help me understand if I'm going in the right direction?

takanome-dev commented 1 year ago

After you upvote or downvote a repo, the voted repos should be refetched and the UI updated.

But I think there is an issue in the API we need to address. See https://github.com/open-sauced/api/issues/122

Feel free to give it a try and let us know how it goes :slightly_smiling_face:

Alexandre-Lustosa-Escossio commented 1 year ago

Hey guys, since my time is short and I can't tackle the backend issues that avoid me from solving this one I'll leave this one open for someone who has more free time!

JDGuillaume commented 1 year ago

Updated post to reflect additional insight.

Would love to .take this one. New to open source, but I've worked with React previously.

Based on the traffic listed in the Network tab, it appears that the page is essentially DDoSing the provided Supabase endpoint. On the initial payload, I'm observing approximately 112 requests to the database. Without interacting with the page, the number of requests to Supabase are continuing to grow.

As @bdougie suggested, I think that the useEffect dependency in the useVotedRepos component may be to blame. It's triggering an infinite rerender or so it appears.

Screen Shot 2023-07-26 at 5 39 00 PM

github-actions[bot] commented 1 year ago

Thanks for taking this on! If you have not already, join the conversation in our Discord

github-actions[bot] commented 1 year ago

Thanks for being interested in this issue. It looks like this ticket is already assigned to a contributor. Please communicate with the assigned contributor to confirm the status of the issue.