uclaacm / TeachLAFrontend

🌱 The frontend for Teach LA's online IDE, designed to teach kids how to code!
https://editor.uclaacm.com
MIT License
21 stars 40 forks source link

Encode current program into URL as `/editor/:programid`, push to browser history #1046

Closed TomBinford closed 1 year ago

TomBinford commented 1 year ago

Closes #746 This makes the URL reflect the current program, which used to live only in mostRecentProgram in the Redux state. On page load, the URL acts as a source of truth to set mostRecentProgram. After that point, we want Redux to be the source of truth so the URL will change whenever mostRecentProgram is set. This conveniently leaves the existing calls to setMostRecentProgram untouched.

This is also integrated with browser history so switching between files will let the forward/back buttons work as you expect.

netlify[bot] commented 1 year ago

Deploy request for sleepy-franklin-7a3e4c pending review.

Visit the deploys page to approve it

Name Link
Latest commit 1a013b1df96ba2a7451f81ea5c017d6efb201ed7
TomBinford commented 1 year ago

Follow-up: if a user shares a link like /editor/someprogramid, we should redirect other users (anyone but the owner) who use that link to /p/someprogramid. I haven't tested what would happen currently but I know it doesn't redirect.