Skip to content

Added the localStorage in the editor.#39

Open
Siddhartha20242 wants to merge 1 commit intohyperjump-io:mainfrom
Siddhartha20242:localstorage
Open

Added the localStorage in the editor.#39
Siddhartha20242 wants to merge 1 commit intohyperjump-io:mainfrom
Siddhartha20242:localstorage

Conversation

@Siddhartha20242
Copy link
Copy Markdown

I noticed while adding localStorage that switching between json and yaml was overwriting whatever was in the other format, and refreshing the page wiped everything out entirely. fixed it by saving the editor state to localStorage and giving json and yaml their own separate keys so they don't step on each other - this is the main one as i had to overwrite a lot of things due to this.

Screen.Recording.2026-03-16.at.11.33.47.PM.mov

got a reference from here too and stackoverflow too- https://www.reddit.com/r/sveltejs/comments/1d43d8p/svelte_5_runes_with_localstorage_thanks_to_joy_of/

@Siddhartha20242
Copy link
Copy Markdown
Author

Hi, @jdesrosiers could you look this up in free time. Thank you:) Would love any new recommendations if i can add to this PR.

Copy link
Copy Markdown
Collaborator

@jdesrosiers jdesrosiers left a comment

Choose a reason for hiding this comment

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

I think the right way to do this is to use a svelte store instead of working directly with localStorage. See, src/stores/settings and src/components/Settings.svelte for an example.

fixed it by saving the editor state to localStorage and giving json and yaml their own separate keys so they don't step on each other

Saving the selected format to localStorage is the right idea, but storing separate values for each format isn't. You should only need to store what's current. When the user loads the page, if they had YAML selected, they'll have their YAML restored.

I think the problem you're describing is that when you toggle formats, you restart with an empty state. That's expected but is being addressed in #37, so don't worry about it.

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.

2 participants