Closed 0xdevalias closed 5 months ago
Done, it now saves and shows a prompt for 5s when loading the site Can you try it? https://deploy-preview-79--webcrack.netlify.app/
Done, it now saves and shows a prompt for 5s when loading the site Can you try it?
@j4k0xb That is pretty cool!
A few notes:
Also did a little code review with some thoughts/notes added there:
While this offers a nice 'recovery option', my original thinking (and still likely better UX for me) would probably be to warn with a 'you have unsaved changes, are you sure you want to leave' sort of confirmation. If this would be annoying for people, maybe making it configurable would work
True, gonna add that
Adding a config might not even be necessary because browsers show that option
Nvm still needed, it resets after a reload
I'll probably remove the restore alert (annoying when it appears on pretty much every site load) and think of some other place in the sidebar that can be used at any time, which should also result in better UX
True, gonna add that
@j4k0xb Awesome!
I'll probably remove the restore alert and think of some other place in the sidebar that can be used at any time
@j4k0xb nods sounds good. I agree that that feels like a better UX as well.
Maybe instead of just saving the files 'as is', there could be some notion of like a 'session' or similar that they get saved into? Not sure if this is overengineering it, but was sort of thinking in terms of thinking a bit like Chrome tab history/restore/similar.
Like, a completely arbitrary off the top of my head example could be that when the web app loads, it creates a UUID for that current session, and then any files that are written to storage are keyed with that UUID (and probably a 'last updated' timestamp; perhaps for the session overall, and the file).
Then in the 'restore UI', it could show the last X sessions (sorted by timestamp); or something to that effect.
(With this, was mostly thinking that since the 'restore state' is going to persist longer than 5sec now; it might make sense to try and scope/group the 'files' a bit more 'logically'; so that a new session doesn't inadvertently wipe out the old one)
Just had a chance to quickly test this now that #79 has landed.
Trying to refresh the page (with unsaved content):
Trying to navigate away from the page (with unsaved content):
If I do reload/navigate away, when I come back, I can attempt to restore from the 'File' -> 'Open Recent' menu:
>
) or similar to make it more obvious that it's a sub-menu
But when I clicked on it, it didn't seem to actually restore the item at all.
It would be cool if the web IDE allowed us to save to browser storage, or at the very least showed a popup/confirmation if we try to navigate away from /refresh the page while working on something.
I'm not sure why my muscle memory was doing it, but I kept hitting cmd+R to try and rename variables yesterday, and lost my in-progress work like 5 times before I managed to force myself to stop pressing it.
Potentially relevant: