fix(ui): fix image nodes losing image

This commit is contained in:
psychedelicious 2023-05-22 20:05:20 +10:00 committed by Kent Keirsey
parent 6aebe1614d
commit 4a7a5234df
3 changed files with 8 additions and 17 deletions

View File

@ -21,7 +21,7 @@ const ImageInputFieldComponent = (
const getImageByNameAndType = useGetImageByNameAndType();
const dispatch = useAppDispatch();
const [url, setUrl] = useState<string>();
const [url, setUrl] = useState<string | undefined>(field.value?.image_url);
const { getUrl } = useGetUrl();
const handleDrop = useCallback(
@ -39,16 +39,13 @@ const ImageInputFieldComponent = (
return;
}
setUrl(image.url);
setUrl(image.image_url);
dispatch(
fieldValueChanged({
nodeId,
fieldName: field.name,
value: {
image_name: name,
image_type: type,
},
value: image,
})
);
},

View File

@ -11,7 +11,7 @@ import {
NodeChange,
OnConnectStartParams,
} from 'reactflow';
import { ImageField } from 'services/api';
import { ImageDTO } from 'services/api';
import { receivedOpenAPISchema } from 'services/thunks/schema';
import { InvocationTemplate, InvocationValue } from '../types/types';
import { parseSchema } from '../util/parseSchema';
@ -65,13 +65,7 @@ const nodesSlice = createSlice({
action: PayloadAction<{
nodeId: string;
fieldName: string;
value:
| string
| number
| boolean
| Pick<ImageField, 'image_name' | 'image_type'>
| RgbaColor
| undefined;
value: string | number | boolean | ImageDTO | RgbaColor | undefined;
}>
) => {
const { nodeId, fieldName, value } = action.payload;

View File

@ -1,6 +1,6 @@
import { OpenAPIV3 } from 'openapi-types';
import { RgbaColor } from 'react-colorful';
import { ImageField } from 'services/api';
import { ImageDTO } from 'services/api';
import { AnyInvocationType } from 'services/events/types';
export type InvocationValue = {
@ -179,7 +179,7 @@ export type ConditioningInputFieldValue = FieldValueBase & {
export type ImageInputFieldValue = FieldValueBase & {
type: 'image';
value?: Pick<ImageField, 'image_name' | 'image_type'>;
value?: ImageDTO;
};
export type ModelInputFieldValue = FieldValueBase & {
@ -245,7 +245,7 @@ export type BooleanInputFieldTemplate = InputFieldTemplateBase & {
};
export type ImageInputFieldTemplate = InputFieldTemplateBase & {
default: Pick<ImageField, 'image_name' | 'image_type'>;
default: ImageDTO;
type: 'image';
};