Skip to content

Persists Redux store to/from sessionStorage #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 20, 2017

Conversation

andrewn
Copy link
Member

@andrewn andrewn commented Apr 5, 2017

As required by #329 we need this for login so the user's work isn't lost.

  • saves the Redux store to sessionStorage when the route changes to /login or /signup
  • disables the "Are you sure" alert
  • reinstates the store and clears from sessionStorage when the App loads

local/sessionStorage is only available for the current origin, so data saved under http is not available under https. This should be ok for the login use case as we'll redirect back to same protocol.

I initially tried to keep the whole store synced to sessionStorage. This gives you some nice features like being able to refresh the page and not losing any data, but I think this would be a lot more work to make work properly.

@andrewn andrewn mentioned this pull request Apr 5, 2017
@andrewn andrewn changed the title [WIP] Persists entire Redux store to/from sessionStorage [Feedback] Persists entire Redux store to/from sessionStorage Apr 6, 2017
@andrewn andrewn force-pushed the feature/persist-local-state branch from c948b56 to 34c4f7f Compare April 9, 2017 16:59
@andrewn andrewn changed the title [Feedback] Persists entire Redux store to/from sessionStorage Persists Redux store to/from sessionStorage Apr 9, 2017
@andrewn
Copy link
Member Author

andrewn commented Apr 9, 2017

@catarak I think this is ready for review.

I've manually tested this by logging in/out a few times. Saving projects and loading them again. It seems ok but I think you might be able to find some edge cases.

@catarak
Copy link
Member

catarak commented Apr 12, 2017

This is working for me if you start on http, but if you open the page on https, and then login or sign up, then it is redirected back to http. Maybe there's something up with the https redirection that we didn't catch? Let me know if you can reproduce this.

@andrewn
Copy link
Member Author

andrewn commented Apr 12, 2017

This is because we use the project's serveSecure flag to indicate whether to redirect back to HTTP or not. All new projects are created with serveSecure: false so it will always redirect back to HTTP.

Maybe new projects started on HTTPS should be created with the serveSecure: true?

@catarak
Copy link
Member

catarak commented Apr 13, 2017

Got it. My instinct is that for now, new projects started on HTTPS should be created with serveSecure: true. Once there is a UI element indicating this to the user, it will be more clear whether the sketch should be served with HTTP or HTTPS.

@andrewn
Copy link
Member Author

andrewn commented Apr 14, 2017

Projects created on HTTPS now have serveSecure: true.

But... because of this, using this flag to figure out if we should redirect or not won't work as the blank project created on HTTPS will have serveSecure: true set even though it's not the real project we want to go back to. 😭

So, I'm appending the querystring parameter ?source=<protocol> when we changing protocol. This is used to figure out which protocol to redirect back to. Not as elegant as I'd like :-(

@catarak catarak merged commit a267837 into processing:master Apr 20, 2017
@catarak
Copy link
Member

catarak commented Apr 20, 2017

Just tested this and it works great 🎉 I think the query string parameter is okay, as login/signup aren't urls that users will copy and paste.

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