Skip to content

Commit e3a75a8

Browse files
fix(ui): fix logic to reset selected/auto-add boards when toggling show archived boards
The logic was incorrect in two ways: 1. We only ran the logic if we _enable_ showing archived boards. It should be run we we _disable_ showing archived boards. 2. If we couldn't find the selected board in the query cache, we didn't do the reset. This is wrong - if the board isn't in the query cache, we _should_ do the reset. This inverted logic makes more sense before the fix for issue 1.
1 parent ee7503c commit e3a75a8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/addArchivedOrDeletedBoardListener.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
7171
const shouldShowArchivedBoards = action.payload;
7272

7373
// We only need to take action if we have just hidden archived boards.
74-
if (!shouldShowArchivedBoards) {
74+
if (shouldShowArchivedBoards) {
7575
return;
7676
}
7777

@@ -86,14 +86,16 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
8686

8787
// Handle the case where selected board is archived
8888
const selectedBoard = queryResult.data.find((b) => b.board_id === selectedBoardId);
89-
if (selectedBoard && selectedBoard.archived) {
89+
if (!selectedBoard || selectedBoard.archived) {
90+
// If we can't find the selected board or it's archived, we should reset the selected board to uncategorized
9091
dispatch(boardIdSelected({ boardId: 'none' }));
9192
dispatch(galleryViewChanged('images'));
9293
}
9394

9495
// Handle the case where auto-add board is archived
9596
const autoAddBoard = queryResult.data.find((b) => b.board_id === autoAddBoardId);
96-
if (autoAddBoard && autoAddBoard.archived) {
97+
if (!autoAddBoard || autoAddBoard.archived) {
98+
// If we can't find the auto-add board or it's archived, we should reset the selected board to uncategorized
9799
dispatch(autoAddBoardIdChanged('none'));
98100
}
99101
},

0 commit comments

Comments
 (0)