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

Implement switch list using useNavigate #48

Merged
merged 6 commits into from Jun 6, 2023
Merged

Implement switch list using useNavigate #48

merged 6 commits into from Jun 6, 2023

Conversation

shahx95
Copy link
Collaborator

@shahx95 shahx95 commented May 24, 2023

Draft PR to discuss an alternative implementation for Switch List

@github-actions
Copy link

github-actions bot commented May 24, 2023

Visit the preview URL for this PR (updated for commit 85e995b):

https://tcl-60-smart-shopping-list--pr48-switchtoken-sgja818g.web.app

(expires Sat, 03 Jun 2023 13:59:10 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 93ba99965233232f14cf05d9d95de4adc510bd3b

@shahx95
Copy link
Collaborator Author

shahx95 commented May 24, 2023

Problem:
When I click on Switch List, it clears the local storage but redirects to "/list" instead of "/"

@shahx95 shahx95 requested review from RajGM and shagunZ and removed request for shagunZ May 25, 2023 10:38
@RajGM
Copy link
Collaborator

RajGM commented May 26, 2023

Problem: When I click on Switch List, it clears the local storage but redirects to "/list" instead of "/"

Even when I click on Home it's redirecting to /list not to /

@RajGM
Copy link
Collaborator

RajGM commented May 26, 2023

Main trouble is / is being redirected to /list

@shagunZ shagunZ marked this pull request as ready for review May 27, 2023 07:49
Use clearListToken function to clear local storage.
@shahx95
Copy link
Collaborator Author

shahx95 commented May 27, 2023

Solution to the aforementioned problem:

Previously, the token was being directly removed from localStorage instead of utilizing setListToken() to update the list token state. This caused a mismatch between the localStorage and the state. When switch list was clicked, the token was removed from localStorage, but it still existed in listToken state. As a result, we saw a redirection to /list as per the homepage logic.

The problem has been addressed by creating a clearListToken function in the app which sets listToken to null. The clearListToken runs when switch list is clicked. By doing so, we resolve the discrepancy and ensure proper redirection to the homepage.

@labrocadabro
Copy link
Collaborator

Screen Shot 2023-05-27 at 6 31 16 PM
We've got an extra switch list link

@shahx95
Copy link
Collaborator Author

shahx95 commented May 27, 2023

Screen Shot 2023-05-27 at 6 31 16 PM We've got an extra switch list link

Thanks. Taken care of.
image

Copy link
Collaborator

@labrocadabro labrocadabro 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!

@shahx95 shahx95 merged commit aa2c627 into main Jun 6, 2023
2 checks passed
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.

None yet

3 participants