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

Inappropriate Use of Window Reload in updatePostHandler Function #1002

Closed
skbhagat0502 opened this issue Oct 23, 2023 · 7 comments
Closed

Inappropriate Use of Window Reload in updatePostHandler Function #1002

skbhagat0502 opened this issue Oct 23, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@skbhagat0502
Copy link
Contributor

Issue Description:

Context:
The updatePostHandler function in the orgPostCard component contains a call to window.location.reload() after a post update. In Single Page Applications (SPAs), this practice is not ideal as it disrupts the seamless user experience that SPAs aim to provide.

Issues Identified:

Full Page Reload:

The use of window.location.reload() results in a full page reload. In SPAs, this can lead to a loss of the benefits associated with dynamic content updates without full page reloads.
setTimeout Usage:

The use of setTimeout to delay the page reload raises concerns. In SPAs, it's generally preferred to handle timing and side effects using React's useEffect hook for better control but here the setTimeOut is not required though.

Loss of SPA Advantages:

Reloading the entire page contradicts the principles of Single Page Applications, where the goal is to provide a smoother and more dynamic user experience.

image

The same issue can be seen with the deletePost

image

Here also after deleting a post the full page reloads and with a setTimeOut.

@skbhagat0502 skbhagat0502 added the bug Something isn't working label Oct 23, 2023
@skbhagat0502
Copy link
Contributor Author

@palisadoes , Please assign me this issue.

@palisadoes
Copy link
Contributor

What is your proposed solution? @rishav-jha-mech may have comments too.

@skbhagat0502
Copy link
Contributor Author

@palisadoes , My approach is simple. Here is my approach.
When creating a post, after successufull creation the refetch function is called to get the updated lists of posts without reloading. With the same approach, we can resolve the issue. Like in case of updating and deleting a post the refetch function is called with the help of props and the refetch function is also passsed as a props. thus it updates the result.
I am making a pull request you can see my solution also.

@skbhagat0502
Copy link
Contributor Author

@palisadoes , I found the same issue with the login functionality also. Here you can see in the video that how after hitting the login button it redirects user to the same login page and after full reloading it redirects to the application.

2023-10-24.06-42-59.mp4

Should I create a new issue for this?

@rishav-jha-mech
Copy link
Contributor

@skbhagat0502 the issue you are addressing comes under Post Feed management and currently @aashimawadhwa has an open PR for that. Before opening any PRs, make sure you are assigned the issue, please read the contributing guidelines.

@skbhagat0502
Copy link
Contributor Author

ok @rishav-jha-mech

@palisadoes
Copy link
Contributor

@skbhagat0502 I'm going to close this, however there are other places in the app where we have to refresh the page after updating values. Creating a standardized methodology to eliminate this need would be good for the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants