fix: persist habits and pomodoro state in localstorage (#304)#342
Open
nitishchaubeyy wants to merge 4 commits into
Open
fix: persist habits and pomodoro state in localstorage (#304)#342nitishchaubeyy wants to merge 4 commits into
nitishchaubeyy wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Owner
|
If your PR still shows the old failed Vercel check, please rebase (or merge the latest main branch into your branch) and push again to trigger a fresh deployment/check run. |
Contributor
Author
|
Hey @indresh404, I synced the branch with the latest main and pushed again to trigger the deployment. I also ran npm run build and npm run lint locally, and everything compiles perfectly without any errors on my end. Since I don't have access to the Vercel logs, could you please check if it's failing due to a missing Environment Variable or a caching issue on Vercel's end? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR resolves #304 by ensuring that user progress in the CodingOwl component is persisted across page refreshes and navigation. Previously, all state was held in volatile useState hooks, causing data loss whenever the component unmounted.
Key Changes
Habit Persistence: Implemented lazy initialization and useEffect syncs for the habit checklist, ensuring completion status is saved and hydrated via localStorage.
Pomodoro Resilience: Transitioned the timer logic from a simple timeLeft state to an endTime timestamp-based calculation. This allows the timer to seamlessly resume countdowns even if the user refreshes the page or navigates away.
State Recovery: Added cleanup logic to clear expired session storage, ensuring the timer resets correctly after completion.
Fixes #304