Open samselikoff opened 4 years ago
We don't want to create a new sandbox on the server whenever someone visits /repl, so we're going to generate the ids on the client and only create one on the server once they hit Save. Therefore the client will always need to send over the ID when creating a sandbox.
New plan:
/repl
with unsaved changes, user can click Save which uses a clientside generated id (so we can make pretty ids), a clientside generated editing token, and a clientside generated browser_id. It sends this over along with the data and creates a sandbox on server. User is redirected to /repl/abc
. User's editing token and browser_id is saved in localStorage./repl/abc
, user fetches sandbox from server with all data except for editing token. (Editing token is hidden from reads). User starts editing and status bar changes to "You have unsaved changes."
localStorage.browser_id
matches repl.browser_id
, Button in title bar says "Save". When clicked, REPL is updated and message clears. (Backend verifies editing token matches).repl.browser_id
(either different or blank), Button in title bar says "Fork and save". When clicked, client generates new REPL data (id, editing token, maybe browser_id if they don't already have one) and creates new REPL on server. User redirected to new URL /repl/def
and message clears.
/repl
, new repl is created, user is redirected to their unique REPL url/repl/123
, and user is given edit token in localStorage./repl/123
, and user with token starts editing, status bar says "You have unsaved changes." Button in title bar says "Save". When clicked, REPL is updated and message clears./repl/123
, and user without token starts editing, status bar says "You have unsaved changes." Button in title bar says "Fork and save". When clicked, new REPL is created, user redirected to new URL/repl/456
, and message clears.