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 likecount bug on favourite page #653

Merged
merged 2 commits into from
Jul 4, 2023

Conversation

Palakkgoyal
Copy link
Contributor

@Palakkgoyal Palakkgoyal commented Jul 4, 2023

This PR fixed issue no. #627
The bug was due to the likecount array was not getting updated. On the home page the whenever we click the like button, updated props are passed to the Post component but, on favorite page when we click on the like button the props were not getting updated due to which I had to fetch the post itself in the Post component.

I think we also don't need to pass post(prop) to the Post component. As we are passing the postId as prop we can get all the updated data there(Post component) itself. What do you think @narayan954 ?

DummyGram.-.Google.Chrome.2023-07-04.18-54-05.mp4

Copy link
Owner

@narayan954 narayan954 left a comment

Choose a reason for hiding this comment

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

looks good to me!

@narayan954
Copy link
Owner

This PR fixed issue no. #627 The bug was due to the likecount array was not getting updated. On the home page the whenever we click the like button, updated props are passed to the Post component but, on favorite page when we click on the like button the props were not getting updated due to which I had to fetch the post itself in the Post component.

I think we also don't need to pass post(prop) to the Post component. As we are passing the postId as prop we can get all the updated data there(Post component) itself. What do you think @narayan954 ?

DummyGram.-.Google.Chrome.2023-07-04.18-54-05.mp4

If we pass id only we'd need to fetch individual post from db each by id for rendering. Currently We're passing the data to be rendered directly. Data for 10 posts(pagination limit) is generated in one query this way instead of querying for each id and rendered.

This'd be like, if 1 query takes 200ms, 10 queries would take 2000ms and hence a delay in generating our home page posts which can be avoided by making a single query.
Our main concern is to reduce db calls .

@narayan954
Copy link
Owner

This PR fixed issue no. #627 The bug was due to the likecount array was not getting updated. On the home page the whenever we click the like button, updated props are passed to the Post component but, on favorite page when we click on the like button the props were not getting updated due to which I had to fetch the post itself in the Post component.
I think we also don't need to pass post(prop) to the Post component. As we are passing the postId as prop we can get all the updated data there(Post component) itself. What do you think @narayan954 ?
DummyGram.-.Google.Chrome.2023-07-04.18-54-05.mp4

If we pass id only we'd need to fetch individual post from db each by id for rendering. Currently We're passing the data to be rendered directly. Data for 10 posts(pagination limit) is generated in one query this way instead of querying for each id and rendered.

This'd be like, if 1 query takes 200ms, 10 queries would take 2000ms and hence a delay in generating our home page posts which can be avoided by making a single query. Our main concern is to reduce db calls .

what do you think now?

@narayan954 narayan954 linked an issue Jul 4, 2023 that may be closed by this pull request
@narayan954 narayan954 merged commit 2eec052 into narayan954:master Jul 4, 2023
5 of 7 checks passed
@Palakkgoyal
Copy link
Contributor Author

This PR fixed issue no. #627 The bug was due to the likecount array was not getting updated. On the home page the whenever we click the like button, updated props are passed to the Post component but, on favorite page when we click on the like button the props were not getting updated due to which I had to fetch the post itself in the Post component.
I think we also don't need to pass post(prop) to the Post component. As we are passing the postId as prop we can get all the updated data there(Post component) itself. What do you think @narayan954 ?
DummyGram.-.Google.Chrome.2023-07-04.18-54-05.mp4

If we pass id only we'd need to fetch individual post from db each by id for rendering. Currently We're passing the data to be rendered directly. Data for 10 posts(pagination limit) is generated in one query this way instead of querying for each id and rendered.
This'd be like, if 1 query takes 200ms, 10 queries would take 2000ms and hence a delay in generating our home page posts which can be avoided by making a single query. Our main concern is to reduce db calls .

what do you think now?

Yes, I think you are right. A single query reduces the number of network round trips and improves overall performance hence, reducing network overhead. Thanks for explaining :)

@Palakkgoyal Palakkgoyal deleted the postNavBug branch July 5, 2023 02:30
narayan954 added a commit that referenced this pull request Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Bug in favorite page post nav
2 participants