Refactor persistent data storage code and add button to wipe data on crash (#827)

* Organize persistence.ts

* Switch to simpler promise handling

* Switch document list storage from localStorage to IndexedDB

* Track document auto-save status to avoid re-auto-saving unnecessarily

* Add button to clear storage on crash

* Bump document version and test file

* Switch to IDB-Keyval instead of raw IDB transactions
This commit is contained in:
Keavon Chambers 2022-11-02 15:19:04 -07:00
parent 73233169b2
commit 9d56e86203
16 changed files with 183 additions and 187 deletions

View file

@ -207,6 +207,7 @@ impl JsEditorHandle {
let message = PortfolioMessage::OpenDocumentFileWithId {
document_id,
document_name,
document_is_auto_saved: true,
document_is_saved,
document_serialized_content,
};

View file

@ -9,7 +9,12 @@ use wasm_bindgen::prelude::*;
/// When a panic occurs, notify the user and log the error to the JS console before the backend dies
pub fn panic_hook(info: &panic::PanicInfo) {
let header = "The editor crashed — sorry about that";
let description = "An internal error occurred. Reload the editor to continue. Please report this by filing an issue on GitHub.";
let description = "
An internal error occurred. Please report this by filing an issue on GitHub.\n\
\n\
Reload the editor to continue. If this happens immediately on repeated reloads, clear saved data.
"
.trim();
error!("{}", info);