Skip to content
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

AF-26 Autosave #90

Merged
merged 4 commits into from
Jul 24, 2023
Merged

AF-26 Autosave #90

merged 4 commits into from
Jul 24, 2023

Conversation

mikecarenzo
Copy link
Contributor

@mikecarenzo mikecarenzo commented Jul 21, 2023

Overview

Implements basic autosave functionality.

image

The builder now logs all document edits to localStorage. If the builder closes with unsaved changes, the unsaved changes can be recovered via the Open Recovered Files submenu. This menu is only visible when there exist documents with unsaved changes.

Simply click on a recovered file to begin editing it. Once saved, the recovered file will disappear from the Open Recovered Files submenu.

You can also clear the recovered files list at any time by clicking Delete Recovered Files under the Open Recovered Files submenu.

Implementation Notes

The original plan involved leveraging the File System Access API. Unfortunately, the FileSystemWritableFileStream construct, required to write changes back to the file system, is still not fully supported by all 5 of the major internet browsers. In order to achieve the greatest level of compatibility, localStorage was chosen instead.

IMPORTANT:

Accessing the application from a webserver will not present issues for autosave. The same cannot be said when opening the application locally via the compiled index.html file. In this case, the behavior of localStorage varies from browser to browser.

Per Mozilla:

For documents loaded from file: URLs (that is, files opened in the browser directly from the user's local filesystem, rather than being served from a web server) the requirements for localStorage behavior are undefined and may vary among different browsers.

In all current browsers, localStorage seems to return a different object for each file: URL. In other words, each file: URL seems to have its own unique local-storage area. But there are no guarantees about that behavior, so you shouldn't rely on it because, as mentioned above, the requirements for file: URLs remain undefined. So it's possible that browsers may change their file: URL handling for localStorage at any time. In fact some browsers have changed their handling for it over time.

@mikecarenzo mikecarenzo requested a review from mehaase July 21, 2023 01:50
@mikecarenzo mikecarenzo self-assigned this Jul 21, 2023
Copy link
Contributor

@mehaase mehaase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with a few comments and questions.

@sonarcloud
Copy link

sonarcloud bot commented Jul 24, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mikecarenzo mikecarenzo merged commit eb2b02d into main Jul 24, 2023
3 of 5 checks passed
@mikecarenzo mikecarenzo deleted the AF-26_auto_save branch July 24, 2023 17:44
@mikecarenzo mikecarenzo linked an issue Aug 18, 2023 that may be closed by this pull request
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.

Saving progress and avoiding data loss
2 participants