Start serializing UI state

This commit is contained in:
space-nuko
2023-05-04 10:29:44 -05:00
parent fd417c6759
commit 93cf2ed98a
8 changed files with 294 additions and 149 deletions

View File

@@ -16,24 +16,11 @@
let app: ComfyApp | null = null;
let serializedPaneOrder = {};
function doAutosave(graph: LGraph): void {
const savedWorkflow = app.serialize();
localStorage.setItem("workflow", JSON.stringify(savedWorkflow))
}
function doRestore(workflow: SerializedAppState) {
serializedPaneOrder = workflow.panes;
}
onMount(async () => {
if (app)
return
app = $uiState.app = new ComfyApp();
app.eventBus.on("autosave", doAutosave);
app.eventBus.on("restored", doRestore);
app.api.addEventListener("status", (ev: CustomEvent) => {
queueState.statusUpdated(ev.detail as ComfyAPIStatus);