-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: add ability to save files #204
Conversation
Codecov Report
@@ Coverage Diff @@
## main #204 +/- ##
==========================================
+ Coverage 71.99% 72.13% +0.14%
==========================================
Files 97 99 +2
Lines 4859 4974 +115
Branches 391 405 +14
==========================================
+ Hits 3498 3588 +90
- Misses 1344 1369 +25
Partials 17 17
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Exciting that we can persist files now! Two questions:
|
|
@danvk we've had to update the references model (FE), and since we persist that information in the localStorage sometimes you need to reset that info using the UI (i.e. "DEBUG: reset references store") or directly via dev tools (Application > Storage). I normally also run the ![]() |
This adds the ability to save files:
File
->Save
Screen.Recording.2023-06-27.at.13.06.39.mov
Implementation choices:
Four atoms are available for files:
loadableFileAtom
is the atom containing the loadable file (the state isloading
when initially reading the file from disk, and should stayhasData
afterwards)updateFileBufferAtom
updates a buffer atom. This is currently updated on every update in the editor. The need of a buffer comes from the fact that updating the actual atom triggers a re-render of the editor, that deletes the history and resets focussaveFileInMemoryAtom
saves the content of the buffer in theloadableFileAtom
. This atom is currently called when an editor instance is unmounted (ie. when switching between tabs)saveFileAtom
actually writes the content of the buffer on the disk. It does NOT update theloadableFileAtom
, to prevent the editor from re-rendering and resetting focus and history.Closes #197