From 0f65a12cf39f62dabeeab3aa9c59923124a4b6fd Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 12 Jul 2024 10:15:18 +1000 Subject: [PATCH] fix(ui): handle archived boards like other boards when they are visible, do not reset board selection when autoadd board is hidden --- .../addArchivedOrDeletedBoardListener.ts | 38 ++++--------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/addArchivedOrDeletedBoardListener.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/addArchivedOrDeletedBoardListener.ts index 8e0a63fc7d..1581da9b37 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/addArchivedOrDeletedBoardListener.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/addArchivedOrDeletedBoardListener.ts @@ -31,19 +31,13 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis return; } - let didReset = false; - - if (!queryResult.data.find((board) => board.board_id === autoAddBoardId)) { - dispatch(autoAddBoardIdChanged('none')); - didReset = true; - } if (!queryResult.data.find((board) => board.board_id === selectedBoardId)) { dispatch(boardIdSelected({ boardId: 'none' })); - didReset = true; - } - if (didReset) { dispatch(galleryViewChanged('images')); } + if (!queryResult.data.find((board) => board.board_id === autoAddBoardId)) { + dispatch(autoAddBoardIdChanged('none')); + } }, }); @@ -90,25 +84,17 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis return; } - let didReset = false; - // Handle the case where selected board is archived const selectedBoard = queryResult.data.find((b) => b.board_id === selectedBoardId); if (selectedBoard && selectedBoard.archived) { dispatch(boardIdSelected({ boardId: 'none' })); - didReset = true; + dispatch(galleryViewChanged('images')); } // Handle the case where auto-add board is archived const autoAddBoard = queryResult.data.find((b) => b.board_id === autoAddBoardId); if (autoAddBoard && autoAddBoard.archived) { dispatch(autoAddBoardIdChanged('none')); - didReset = true; - } - - // When resetting the auto-add board or selected board, we should also reset the view to images - if (didReset) { - dispatch(galleryViewChanged('images')); } }, }); @@ -123,25 +109,15 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis const state = getState(); const { selectedBoardId, autoAddBoardId } = state.gallery; - let didReset = false; - // Handle the case where selected board isn't in the list of boards - const selectedBoard = boards.find((b) => b.board_id === selectedBoardId); - if (selectedBoard && selectedBoard.archived) { + if (!boards.find((b) => b.board_id === selectedBoardId)) { dispatch(boardIdSelected({ boardId: 'none' })); - didReset = true; + dispatch(galleryViewChanged('images')); } // Handle the case where auto-add board isn't in the list of boards - const autoAddBoard = boards.find((b) => b.board_id === autoAddBoardId); - if (autoAddBoard && autoAddBoard.archived) { + if (!boards.find((b) => b.board_id === autoAddBoardId)) { dispatch(autoAddBoardIdChanged('none')); - didReset = true; - } - - // When resetting the auto-add board or selected board, we should also reset the view to images - if (didReset) { - dispatch(galleryViewChanged('images')); } }, });