-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add basic URL Encoding for scratchpad text state #1441
base: dev
Are you sure you want to change the base?
Conversation
// Override the load function | ||
let load = (): t => { | ||
switch (JsUtil.QueryParams.get_param(key_string)) { | ||
| Some(data) => | ||
let decompressed = StringUtil.decompress(data); | ||
let zip = Haz3lcore.Printer.zipper_of_string(decompressed); | ||
switch (zip) { | ||
| Some(zip) => (0, [PersistentZipper.persist(zip)]) | ||
| None => init() | ||
}; | ||
| None => | ||
switch (JsUtil.get_localstore(key_string)) { | ||
| None => init() | ||
| Some(data) => deserialize(data, default()) | ||
} | ||
}; | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This blows away all the scratch buffers a user currently has. Not sure how we want to handle it. We could create a new scratch buffer or maybe highjack the active one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my ideal solution here is for the URL to encode some arbitrary partial state -- some of which could be a named scratchpad added to the editor state -- maybe the default names would be protected to prevent malicious links deleting existing work.
Alternatively (and more easily), we could have some "visitor" mode in which your state isn't persisted through traditional methods, and some option to merge the visitor state with your local state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the easiest thing is to just add a third section under scratch and documentation that only shows up if you're using the share url.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol... you're totally right, that's way easier
This branch implements a basic mechanism to encode and retrieve the text state of a scratchpad:
Currently, this takes precedence over the local store.
Example: prime finder
Future potential improvements: