diff --git a/src/lib/components/ComfyApp.ts b/src/lib/components/ComfyApp.ts index e57e3f8..2c43c30 100644 --- a/src/lib/components/ComfyApp.ts +++ b/src/lib/components/ComfyApp.ts @@ -77,14 +77,6 @@ export default class ComfyApp { shiftDown: boolean = false; selectedGroupMoving: boolean = false; - private static _instance: ComfyApp; - - static get instance(): ComfyApp { - if (!ComfyApp._instance) - ComfyApp._instance = new ComfyApp() - return ComfyApp._instance - } - private queueItems: QueueItem[] = []; private processingQueue: boolean = false; diff --git a/src/lib/stores/uiState.ts b/src/lib/stores/uiState.ts index 477d52e..0fbb6b8 100644 --- a/src/lib/stores/uiState.ts +++ b/src/lib/stores/uiState.ts @@ -1,7 +1,9 @@ import { writable } from 'svelte/store'; import type { Readable, Writable } from 'svelte/store'; +import type ComfyApp from "$lib/components/ComfyApp" export type UIState = { + app: ComfyApp, nodesLocked: boolean, graphLocked: boolean, unlocked: boolean, diff --git a/src/mobile/routes/graph.svelte b/src/mobile/routes/graph.svelte index 3ed641f..ca39002 100644 --- a/src/mobile/routes/graph.svelte +++ b/src/mobile/routes/graph.svelte @@ -4,11 +4,15 @@ import ComfyApp, { type SerializedAppState } from "$lib/components/ComfyApp"; import ComfyGraphCanvas from "$lib/ComfyGraphCanvas"; import { onMount } from 'svelte'; + import uiState from "$lib/stores/uiState" - const app: ComfyApp = ComfyApp.instance; + let app: ComfyApp | null = null; let lCanvas: LGraphCanvas | null = null; let canvasEl: HTMLCanvasElement | null = null; + $: if (!app) + app = $uiState.app + function resizeCanvas() { canvasEl.width = canvasEl.parentElement.offsetWidth; canvasEl.height = canvasEl.parentElement.offsetHeight; diff --git a/src/mobile/routes/home.svelte b/src/mobile/routes/home.svelte index c8120e7..5d61f2d 100644 --- a/src/mobile/routes/home.svelte +++ b/src/mobile/routes/home.svelte @@ -18,17 +18,6 @@ let app: ComfyApp | null = null; - function onBackKeyDown(e) { - if(f7.view.current.router.currentRoute.path == '/'){ - // exitApp(); - e.preventDefault(); - } else { - f7.dialog.close() - f7.view.main.router.back() - return false; - } - } - let serializedPaneOrder = {}; function serializeAppState(): SerializedAppState { @@ -56,7 +45,7 @@ onMount(async () => { if (app) return - app = ComfyApp.instance; + app = $uiState.app = new ComfyApp(); // TODO dedup app.eventBus.on("nodeAdded", nodeState.nodeAdded); diff --git a/src/mobile/routes/subworkflow.svelte b/src/mobile/routes/subworkflow.svelte index 94b17b9..d87b345 100644 --- a/src/mobile/routes/subworkflow.svelte +++ b/src/mobile/routes/subworkflow.svelte @@ -21,9 +21,8 @@ export let subworkflowID: number = -1; let app: ComfyApp = undefined; - $: if (ComfyApp.instance) - app = ComfyApp.instance; - + $: if (!app) + app = $uiState.app function queuePrompt() { app.queuePrompt(0, 1);