mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
fix(ui): ensure images are added to gallery in simple sessions
This commit is contained in:
@@ -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']) => {
|
||||
|
||||
Reference in New Issue
Block a user