Skip to content

feat: persistency on game settings & clear button#9

Merged
MrRoiz merged 1 commit intoMrRoiz:mainfrom
csantosr:feature/persistence
Jan 27, 2026
Merged

feat: persistency on game settings & clear button#9
MrRoiz merged 1 commit intoMrRoiz:mainfrom
csantosr:feature/persistence

Conversation

@csantosr
Copy link
Copy Markdown
Collaborator

#6

Note: the load of the storage values into the form looks like an overkill, more knowing that values exist. But it being an atom that we are updating on every change, it create weird behaviors like the input constantly unfocusing

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements persistent game settings using Jotai's atomWithStorage to save form data to localStorage, and adds a "Clear" button to reset settings. This addresses issue #6 where game settings were lost on page reload.

Changes:

  • Converted gameSettingsAtom from a regular atom to atomWithStorage for localStorage persistence
  • Added hydration logic to load saved settings from storage into the form on mount
  • Added a "Clear" button with translations in English and Spanish to reset settings to defaults
  • Implemented auto-save functionality that persists form changes to storage as the user types

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
app/[lang]/game/_store/game-settings.ts Changed from regular atom to atomWithStorage for localStorage persistence
app/[lang]/game/local/setup/_components/form.tsx Added hydration logic, auto-save effect, clear button, and extracted default values to a constant
dictionaries/en.json Added "clear" translation for the clear button
dictionaries/es.json Added "clear" translation ("Limpiar") for the clear button

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/[lang]/game/_store/game-settings.ts
Comment thread app/[lang]/game/local/setup/_components/form.tsx Outdated
Comment thread app/[lang]/game/local/setup/_components/form.tsx Outdated
Comment thread app/[lang]/game/local/setup/_components/form.tsx Outdated
Comment thread app/[lang]/game/local/setup/_components/form.tsx
Comment thread app/[lang]/game/local/setup/_components/form.tsx Outdated
@csantosr csantosr force-pushed the feature/persistence branch from a3e47d4 to f48fb53 Compare January 27, 2026 03:24
@csantosr
Copy link
Copy Markdown
Collaborator Author

@MrRoiz this PR is ready for your review 🫶

@MrRoiz MrRoiz merged commit b003703 into MrRoiz:main Jan 27, 2026
1 check failed
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.

3 participants