Closed jamievicary closed 5 years ago
This looks like a good option: https://github.com/rt2zz/redux-persist-transform-compress
Now working for persisted state in localStorage.
Does anyone know how to hook this into the undo/redo browser buttons?
Does anyone know how to hook this into the undo/redo browser buttons?
I think you would hook into the onpopstate event. You can bind to it with jQuery like so: $(window).on('popstate', function(e) { ... e.originalEvent.state ... })
To stop it from firing when you programmatically change the hash, instead of assigning window.location.hash
you'd want to do use pushState
, e.g. window.history.pushState({}, "", "#foo")
. The first argument ({}
) is a state object that you get back in the popstate
event handler. You can pass anything here; the idea is that it lets the popstate
handler avoid having to deserialize the hash by storing the application's history state directly.
This sounds good, although it would be good to avoid jQuery, it feels a bit weird mixing that with React.
Lukas is currently fixing some issues with state persistence. Once that is done it will be easier to implement this URL idea.
Done and working on master.
Exported workspaces will be very large, easily running into tens of megabytes. We want to be pushing these around a lot --- letting the user download them, putting them on to the history stack for undo/redo, sending them to the server, etc. So I think we need an in-browser way to compress them.