From fee293e28926f84bcc9d34a714a0c81939f8a61c Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:31:26 +1000 Subject: [PATCH] tidy(ui): clean up a few bits and bobs --- .../controlLayers/konva/CanvasManager.ts | 41 ++++++++----------- .../controlLayers/konva/CanvasStagingArea.ts | 7 +--- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasManager.ts b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasManager.ts index 7f1873e4b8..49167fba9d 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasManager.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasManager.ts @@ -14,7 +14,7 @@ import { getPrefixedId, previewBlob, } from 'features/controlLayers/konva/util'; -import type { CanvasV2State, GenerationMode, Rect } from 'features/controlLayers/store/types'; +import type { GenerationMode, Rect } from 'features/controlLayers/store/types'; import type Konva from 'konva'; import { atom } from 'nanostores'; import type { Logger } from 'roarr'; @@ -38,7 +38,9 @@ export class CanvasManager { id: string; path: string[]; - container: HTMLDivElement; + + store: AppStore; + socket: AppSocket; rasterLayerAdapters: Map = new Map(); controlLayerAdapters: Map = new Map(); @@ -54,33 +56,14 @@ export class CanvasManager { cache: CanvasCacheModule; renderer: CanvasRenderingModule; - log: Logger; - socket: AppSocket; - - _store: AppStore; - prevState: CanvasV2State; - isFirstRender: boolean = true; _isDebugging: boolean = false; constructor(stage: Konva.Stage, container: HTMLDivElement, store: AppStore, socket: AppSocket) { this.id = getPrefixedId(this.type); this.path = [this.id]; - this.container = container; - this._store = store; + this.store = store; this.socket = socket; - this.stateApi = new CanvasStateApi(this._store, this); - - this.prevState = this.stateApi.getState(); - - this.log = logger('canvas').child((message) => { - return { - ...message, - context: { - ...this.getLoggingContext(), - ...message.context, - }, - }; - }); + this.stateApi = new CanvasStateApi(this.store, this); this.stage = new CanvasStageModule(stage, container, this); this.worker = new CanvasWorkerModule(this); @@ -95,6 +78,16 @@ export class CanvasManager { this.filter = new CanvasFilter(this); } + log = logger('canvas').child((message) => { + return { + ...message, + context: { + ...this.getLoggingContext(), + ...message.context, + }, + }; + }); + enableDebugging() { this._isDebugging = true; this.logDebugInfo(); @@ -171,7 +164,7 @@ export class CanvasManager { const cleanupEventHandlers = setStageEventHandlers(this); const cleanupStage = this.stage.initialize(); - const cleanupStore = this._store.subscribe(this.renderer.render); + const cleanupStore = this.store.subscribe(this.renderer.render); return () => { this.log.debug('Cleaning up canvas manager'); diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasStagingArea.ts b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasStagingArea.ts index e86a26391f..7b625fe16c 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasStagingArea.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasStagingArea.ts @@ -51,11 +51,7 @@ export class CanvasStagingArea { this.konva.group.position({ x, y }); if (this.selectedImage) { - const { - imageDTO, - // offsetX, // TODO(psyche): restore the crop in the node? - // offsetY // TODO(psyche): restore the crop in the node? - } = this.selectedImage; + const { imageDTO } = this.selectedImage; if (!this.image) { const { image_name } = imageDTO; @@ -63,7 +59,6 @@ export class CanvasStagingArea { { id: 'staging-area-image', type: 'image', - filters: [], image: { image_name: image_name, width,