mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 13:18:12 +08:00
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:
@@ -37,6 +37,8 @@ export class UpdateOpenDocumentsList extends JsMessage {
|
||||
export abstract class DocumentDetails {
|
||||
readonly name!: string;
|
||||
|
||||
readonly isAutoSaved!: boolean;
|
||||
|
||||
readonly isSaved!: boolean;
|
||||
|
||||
readonly id!: bigint | string;
|
||||
@@ -50,6 +52,11 @@ export class FrontendDocumentDetails extends DocumentDetails {
|
||||
readonly id!: bigint;
|
||||
}
|
||||
|
||||
export class IndexedDbDocumentDetails extends DocumentDetails {
|
||||
@Transform(({ value }: { value: bigint }) => value.toString())
|
||||
id!: string;
|
||||
}
|
||||
|
||||
export class TriggerIndexedDbWriteDocument extends JsMessage {
|
||||
document!: string;
|
||||
|
||||
@@ -59,11 +66,6 @@ export class TriggerIndexedDbWriteDocument extends JsMessage {
|
||||
version!: string;
|
||||
}
|
||||
|
||||
export class IndexedDbDocumentDetails extends DocumentDetails {
|
||||
@Transform(({ value }: { value: bigint }) => value.toString())
|
||||
id!: string;
|
||||
}
|
||||
|
||||
export class TriggerIndexedDbRemoveDocument extends JsMessage {
|
||||
// Use a string since IndexedDB can not use BigInts for keys
|
||||
@Transform(({ value }: { value: bigint }) => value.toString())
|
||||
|
||||
Reference in New Issue
Block a user