fix(ui): fix node editor image fields

I had broken this when converting to rtk-query
This commit is contained in:
psychedelicious 2023-06-23 19:29:00 +10:00
parent e386b5dc53
commit e076231398
3 changed files with 9 additions and 10 deletions

View File

@ -26,11 +26,11 @@ const ImageInputFieldComponent = (
isLoading, isLoading,
isError, isError,
isSuccess, isSuccess,
} = useGetImageDTOQuery(field.value ?? skipToken); } = useGetImageDTOQuery(field.value?.image_name ?? skipToken);
const handleDrop = useCallback( const handleDrop = useCallback(
(droppedImage: ImageDTO) => { ({ image_name }: ImageDTO) => {
if (field.value === droppedImage.image_name) { if (field.value?.image_name === image_name) {
return; return;
} }
@ -38,7 +38,7 @@ const ImageInputFieldComponent = (
fieldValueChanged({ fieldValueChanged({
nodeId, nodeId,
fieldName: field.name, fieldName: field.name,
value: droppedImage.image_name, value: { image_name },
}) })
); );
}, },

View File

@ -11,14 +11,13 @@ import {
NodeChange, NodeChange,
OnConnectStartParams, OnConnectStartParams,
} from 'reactflow'; } from 'reactflow';
import { ImageDTO } from 'services/api/types'; import { ImageField } from 'services/api/types';
import { receivedOpenAPISchema } from 'services/api/thunks/schema'; import { receivedOpenAPISchema } from 'services/api/thunks/schema';
import { InvocationTemplate, InvocationValue } from '../types/types'; import { InvocationTemplate, InvocationValue } from '../types/types';
import { parseSchema } from '../util/parseSchema'; import { parseSchema } from '../util/parseSchema';
import { log } from 'app/logging/useLogger'; import { log } from 'app/logging/useLogger';
import { forEach, size } from 'lodash-es'; import { size } from 'lodash-es';
import { RgbaColor } from 'react-colorful'; import { RgbaColor } from 'react-colorful';
import { imageUrlsReceived } from 'services/api/thunks/image';
import { RootState } from 'app/store/store'; import { RootState } from 'app/store/store';
export type NodesState = { export type NodesState = {
@ -66,7 +65,7 @@ const nodesSlice = createSlice({
action: PayloadAction<{ action: PayloadAction<{
nodeId: string; nodeId: string;
fieldName: string; fieldName: string;
value: string | number | boolean | ImageDTO | RgbaColor | undefined; value: string | number | boolean | ImageField | RgbaColor | undefined;
}> }>
) => { ) => {
const { nodeId, fieldName, value } = action.payload; const { nodeId, fieldName, value } = action.payload;

View File

@ -1,6 +1,6 @@
import { OpenAPIV3 } from 'openapi-types'; import { OpenAPIV3 } from 'openapi-types';
import { RgbaColor } from 'react-colorful'; import { RgbaColor } from 'react-colorful';
import { Graph, ImageDTO } from 'services/api/types'; import { Graph, ImageDTO, ImageField } from 'services/api/types';
import { AnyInvocationType } from 'services/events/types'; import { AnyInvocationType } from 'services/events/types';
import { O } from 'ts-toolbelt'; import { O } from 'ts-toolbelt';
@ -214,7 +214,7 @@ export type VaeInputFieldValue = FieldValueBase & {
export type ImageInputFieldValue = FieldValueBase & { export type ImageInputFieldValue = FieldValueBase & {
type: 'image'; type: 'image';
value?: string; value?: ImageField;
}; };
export type ModelInputFieldValue = FieldValueBase & { export type ModelInputFieldValue = FieldValueBase & {