wasdk / WebAssemblyStudio

Learn, Teach, Work and Play in the WebAssembly Studio

Home Page:http://webassembly.studio

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Use Session Storage so code persists across refreshes.

carlsmith opened this issue · comments

When the tab is refreshed, everything is lost, which sucks in a few obvious ways.

A callback bound to onbeforeunload could quickly copy the details from each file to a hash, serialize it with JSON, and stash it to sessionStorage. Then, an onload handler would check sessionStorage and restore the important aspects of the previous state (or bring up the New Project dialog) when the new page loads.

Storing the data in localStorage is a possible alternative, but this request is limited to edits persisting long enough for the user to refresh the page (or close it, change their mind and reopen it a moment later) without losing their work.

One problem with this proposal is that users sometimes want to refresh the page to start a new project. Using the browser UI (outside the Studio) to delete the session data manually before refreshing the tab would be clunky and people will not always make the connection.

One solution would be to add a New Project button (with a confirmation dialog) that deletes sessionStorage then refreshes the page. Another option would be to replace the current exit dialog (that confirms you want to leave) with one that asks if you want to nuke your session on the way out.

Thank you for considering this.

Maybe you could even mix the two and store both localstorage and sessionstorage. On page load, you could maybe copy localstorage (if it exists) to sessionstorage to then read.