From e10e22440daef997f6dc91b85342352ff0f7748b Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 21 Jul 2023 14:29:42 +1000 Subject: [PATCH] fix(ui): restore auto-add to board functionality --- .../socketio/socketInvocationComplete.ts | 48 ++++++++----------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketInvocationComplete.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketInvocationComplete.ts index 97cccfa05c..24cec186be 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketInvocationComplete.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketInvocationComplete.ts @@ -3,6 +3,7 @@ import { addImageToStagingArea } from 'features/canvas/store/canvasSlice'; import { IMAGE_CATEGORIES, boardIdSelected, + galleryViewChanged, imageSelected, } from 'features/gallery/store/gallerySlice'; import { progressImageSet } from 'features/system/store/systemSlice'; @@ -55,34 +56,6 @@ export const addInvocationCompleteEventListener = () => { } if (!imageDTO.is_intermediate) { - // update the cache for 'All Images' - dispatch( - imagesApi.util.updateQueryData( - 'listImages', - { - categories: IMAGE_CATEGORIES, - }, - (draft) => { - imagesAdapter.addOne(draft, imageDTO); - draft.total = draft.total + 1; - } - ) - ); - - // update the cache for 'No Board' - dispatch( - imagesApi.util.updateQueryData( - 'listImages', - { - board_id: 'none', - }, - (draft) => { - imagesAdapter.addOne(draft, imageDTO); - draft.total = draft.total + 1; - } - ) - ); - const { autoAddBoardId } = gallery; // add image to the board if auto-add is enabled @@ -93,6 +66,22 @@ export const addInvocationCompleteEventListener = () => { imageDTO, }) ); + } else { + // add to no board board + // update the cache for 'No Board' + dispatch( + imagesApi.util.updateQueryData( + 'listImages', + { + board_id: 'none', + categories: IMAGE_CATEGORIES, + }, + (draft) => { + imagesAdapter.addOne(draft, imageDTO); + draft.total = draft.total + 1; + } + ) + ); } const { selectedBoardId, shouldAutoSwitch } = gallery; @@ -102,8 +91,9 @@ export const addInvocationCompleteEventListener = () => { // if auto-add is enabled, switch the board as the image comes in if (autoAddBoardId && autoAddBoardId !== selectedBoardId) { dispatch(boardIdSelected(autoAddBoardId)); + dispatch(galleryViewChanged('images')); } else if (!autoAddBoardId) { - dispatch(boardIdSelected('images')); + dispatch(galleryViewChanged('images')); } dispatch(imageSelected(imageDTO.image_name)); }