mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
feat(ui): show toasts when filter, transform, select or crop fails
This commit is contained in:
@@ -2,6 +2,7 @@ import type { Selector } from '@reduxjs/toolkit';
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import type { RootState } from 'app/store/store';
|
||||
import { deepClone } from 'common/util/deepClone';
|
||||
import { withResultAsync } from 'common/util/result';
|
||||
import type { CanvasEntityBufferObjectRenderer } from 'features/controlLayers/konva/CanvasEntity/CanvasEntityBufferObjectRenderer';
|
||||
import type { CanvasEntityFilterer } from 'features/controlLayers/konva/CanvasEntity/CanvasEntityFilterer';
|
||||
import type { CanvasEntityObjectRenderer } from 'features/controlLayers/konva/CanvasEntity/CanvasEntityObjectRenderer';
|
||||
@@ -29,6 +30,7 @@ import {
|
||||
isRasterLayerEntityIdentifier,
|
||||
type Rect,
|
||||
} from 'features/controlLayers/store/types';
|
||||
import { toast } from 'features/toast/toast';
|
||||
import Konva from 'konva';
|
||||
import { atom } from 'nanostores';
|
||||
import rafThrottle from 'raf-throttle';
|
||||
@@ -574,9 +576,16 @@ export abstract class CanvasEntityAdapterBase<
|
||||
return stableHash(arg);
|
||||
};
|
||||
|
||||
cropToBbox = (): Promise<ImageDTO> => {
|
||||
cropToBbox = async (): Promise<ImageDTO> => {
|
||||
const { rect } = this.manager.stateApi.getBbox();
|
||||
return this.renderer.rasterize({ rect, replaceObjects: true, attrs: { opacity: 1, filters: [] } });
|
||||
const rasterizeResult = await withResultAsync(() =>
|
||||
this.renderer.rasterize({ rect, replaceObjects: true, attrs: { opacity: 1, filters: [] } })
|
||||
);
|
||||
if (rasterizeResult.isErr()) {
|
||||
toast({ status: 'error', title: 'Failed to crop to bbox' });
|
||||
throw rasterizeResult.error;
|
||||
}
|
||||
return rasterizeResult.value;
|
||||
};
|
||||
|
||||
destroy = (): void => {
|
||||
|
||||
@@ -11,6 +11,7 @@ import type { FilterConfig } from 'features/controlLayers/store/filters';
|
||||
import { getFilterForModel, IMAGE_FILTERS } from 'features/controlLayers/store/filters';
|
||||
import type { CanvasImageState, CanvasRenderableEntityType } from 'features/controlLayers/store/types';
|
||||
import { imageDTOToImageObject } from 'features/controlLayers/store/util';
|
||||
import { toast } from 'features/toast/toast';
|
||||
import Konva from 'konva';
|
||||
import { debounce } from 'lodash-es';
|
||||
import { atom, computed } from 'nanostores';
|
||||
@@ -246,6 +247,7 @@ export class CanvasEntityFilterer extends CanvasModuleBase {
|
||||
this.parent.renderer.rasterize({ rect, attrs: { filters: [], opacity: 1 } })
|
||||
);
|
||||
if (rasterizeResult.isErr()) {
|
||||
toast({ status: 'error', title: 'Failed to process filter' });
|
||||
this.log.error({ error: serializeError(rasterizeResult.error) }, 'Error rasterizing entity');
|
||||
this.$isProcessing.set(false);
|
||||
return;
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
} from 'features/controlLayers/konva/util';
|
||||
import { selectSelectedEntityIdentifier } from 'features/controlLayers/store/selectors';
|
||||
import type { Coordinate, Rect, RectWithRotation } from 'features/controlLayers/store/types';
|
||||
import { toast } from 'features/toast/toast';
|
||||
import Konva from 'konva';
|
||||
import type { GroupConfig } from 'konva/lib/Group';
|
||||
import { clamp, debounce, get } from 'lodash-es';
|
||||
@@ -779,6 +780,7 @@ export class CanvasEntityTransformer extends CanvasModuleBase {
|
||||
})
|
||||
);
|
||||
if (rasterizeResult.isErr()) {
|
||||
toast({ status: 'error', title: 'Failed to apply transform' });
|
||||
this.log.error({ error: serializeError(rasterizeResult.error) }, 'Failed to rasterize entity');
|
||||
}
|
||||
this.requestRectCalculation();
|
||||
|
||||
@@ -26,6 +26,7 @@ import type {
|
||||
import { SAM_POINT_LABEL_NUMBER_TO_STRING } from 'features/controlLayers/store/types';
|
||||
import { imageDTOToImageObject } from 'features/controlLayers/store/util';
|
||||
import { Graph } from 'features/nodes/util/graph/generation/Graph';
|
||||
import { toast } from 'features/toast/toast';
|
||||
import Konva from 'konva';
|
||||
import type { KonvaEventObject } from 'konva/lib/Node';
|
||||
import { debounce } from 'lodash-es';
|
||||
@@ -571,6 +572,7 @@ export class CanvasSegmentAnythingModule extends CanvasModuleBase {
|
||||
);
|
||||
|
||||
if (rasterizeResult.isErr()) {
|
||||
toast({ status: 'error', title: 'Failed to select object' });
|
||||
this.log.error({ error: serializeError(rasterizeResult.error) }, 'Error rasterizing entity');
|
||||
this.$isProcessing.set(false);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user