Added the localStorage in the editor.#39
Added the localStorage in the editor.#39Siddhartha20242 wants to merge 1 commit intohyperjump-io:mainfrom
Conversation
|
Hi, @jdesrosiers could you look this up in free time. Thank you:) Would love any new recommendations if i can add to this PR. |
jdesrosiers
left a comment
There was a problem hiding this comment.
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.
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/