fix(ui): ensure images are added to gallery in simple sessions

This commit is contained in:
psychedelicious
2025-05-30 21:29:43 +10:00
parent dc31eaa3f9
commit 172142ce03

View File

@@ -23,12 +23,17 @@ const log = logger('events');
const nodeTypeDenylist = ['load_image', 'image'];
export const buildOnInvocationComplete = (getState: () => RootState, dispatch: AppDispatch) => {
const addImagesToGallery = (data: S['InvocationCompleteEvent'], imageDTOs: ImageDTO[]) => {
const addImagesToGallery = async (data: S['InvocationCompleteEvent']) => {
if (nodeTypeDenylist.includes(data.invocation.type)) {
log.trace(`Skipping denylisted node type (${data.invocation.type})`);
return;
}
const imageDTOs = await getResultImageDTOs(data);
if (imageDTOs.length === 0) {
return;
}
// For efficiency's sake, we want to minimize the number of dispatches and invalidations we do.
// We'll keep track of each change we need to make and do them all at once.
const boardTotalAdditions: Record<string, number> = {};
@@ -161,8 +166,7 @@ export const buildOnInvocationComplete = (getState: () => RootState, dispatch: A
upsertExecutionState(nes.nodeId, nes);
}
const imageDTOs = await getResultImageDTOs(data);
addImagesToGallery(data, imageDTOs);
await addImagesToGallery(data);
};
const handleOriginCanvas = async (data: S['InvocationCompleteEvent']) => {
@@ -170,6 +174,8 @@ export const buildOnInvocationComplete = (getState: () => RootState, dispatch: A
return;
}
await addImagesToGallery(data);
// We expect only a single image in the canvas output
const imageDTO = (await getResultImageDTOs(data))[0];
@@ -185,8 +191,7 @@ export const buildOnInvocationComplete = (getState: () => RootState, dispatch: A
};
const handleOriginOther = async (data: S['InvocationCompleteEvent']) => {
const imageDTOs = await getResultImageDTOs(data);
addImagesToGallery(data, imageDTOs);
await addImagesToGallery(data);
};
return async (data: S['InvocationCompleteEvent']) => {