tidy(ui): remove "filter" from CanvasImageState

This commit is contained in:
psychedelicious 2024-08-20 12:50:11 +10:00
parent 285c266612
commit 2a3546db97
2 changed files with 1 additions and 19 deletions

View File

@ -5,7 +5,6 @@ import type { CanvasFilter } from 'features/controlLayers/konva/CanvasFilter';
import type { CanvasManager } from 'features/controlLayers/konva/CanvasManager'; import type { CanvasManager } from 'features/controlLayers/konva/CanvasManager';
import type { CanvasObjectRenderer } from 'features/controlLayers/konva/CanvasObjectRenderer'; import type { CanvasObjectRenderer } from 'features/controlLayers/konva/CanvasObjectRenderer';
import type { CanvasStagingArea } from 'features/controlLayers/konva/CanvasStagingArea'; import type { CanvasStagingArea } from 'features/controlLayers/konva/CanvasStagingArea';
import { FILTER_MAP } from 'features/controlLayers/konva/filters';
import { loadImage } from 'features/controlLayers/konva/util'; import { loadImage } from 'features/controlLayers/konva/util';
import type { CanvasImageState } from 'features/controlLayers/store/types'; import type { CanvasImageState } from 'features/controlLayers/store/types';
import { t } from 'i18next'; import { t } from 'i18next';
@ -137,14 +136,6 @@ export class CanvasImageRenderer {
this.konva.group.add(this.konva.image); this.konva.group.add(this.konva.image);
} }
if (this.state.filters.length > 0) {
this.konva.image.cache();
this.konva.image.filters(this.state.filters.map((f) => FILTER_MAP[f]));
} else {
this.konva.image.clearCache();
this.konva.image.filters([]);
}
this.konva.placeholder.rect.setAttrs({ width, height }); this.konva.placeholder.rect.setAttrs({ width, height });
this.konva.placeholder.text.setAttrs({ width, height, fontSize: width / 16 }); this.konva.placeholder.text.setAttrs({ width, height, fontSize: width / 16 });
@ -161,19 +152,12 @@ export class CanvasImageRenderer {
if (force || this.state !== state) { if (force || this.state !== state) {
this.log.trace({ state }, 'Updating image'); this.log.trace({ state }, 'Updating image');
const { image, filters } = state; const { image } = state;
const { width, height, image_name } = image; const { width, height, image_name } = image;
if (force || (this.state.image.image_name !== image_name && !this.isLoading)) { if (force || (this.state.image.image_name !== image_name && !this.isLoading)) {
await this.updateImageSource(image_name); await this.updateImageSource(image_name);
} }
this.konva.image?.setAttrs({ width, height }); this.konva.image?.setAttrs({ width, height });
if (filters.length > 0) {
this.konva.image?.cache();
this.konva.image?.filters(filters.map((f) => FILTER_MAP[f]));
} else {
this.konva.image?.clearCache();
this.konva.image?.filters([]);
}
this.state = state; this.state = state;
return true; return true;
} }

View File

@ -566,7 +566,6 @@ const zCanvasImageState = z.object({
id: zId, id: zId,
type: z.literal('image'), type: z.literal('image'),
image: zImageWithDims, image: zImageWithDims,
filters: z.array(zLayerEffect),
}); });
export type CanvasImageState = z.infer<typeof zCanvasImageState>; export type CanvasImageState = z.infer<typeof zCanvasImageState>;
@ -806,7 +805,6 @@ export const imageDTOToImageObject = (imageDTO: ImageDTO, overrides?: Partial<Ca
return { return {
id: getObjectId('image'), id: getObjectId('image'),
type: 'image', type: 'image',
filters: [],
image: { image: {
image_name, image_name,
width, width,