Skip to content

Commit 0f65a12

Browse files
fix(ui): handle archived boards like other boards when they are visible, do not reset board selection when autoadd board is hidden
1 parent 84abdc5 commit 0f65a12

File tree

1 file changed

+7
-31
lines changed

1 file changed

+7
-31
lines changed

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

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,13 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
3131
return;
3232
}
3333

34-
let didReset = false;
35-
36-
if (!queryResult.data.find((board) => board.board_id === autoAddBoardId)) {
37-
dispatch(autoAddBoardIdChanged('none'));
38-
didReset = true;
39-
}
4034
if (!queryResult.data.find((board) => board.board_id === selectedBoardId)) {
4135
dispatch(boardIdSelected({ boardId: 'none' }));
42-
didReset = true;
43-
}
44-
if (didReset) {
4536
dispatch(galleryViewChanged('images'));
4637
}
38+
if (!queryResult.data.find((board) => board.board_id === autoAddBoardId)) {
39+
dispatch(autoAddBoardIdChanged('none'));
40+
}
4741
},
4842
});
4943

@@ -90,25 +84,17 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
9084
return;
9185
}
9286

93-
let didReset = false;
94-
9587
// Handle the case where selected board is archived
9688
const selectedBoard = queryResult.data.find((b) => b.board_id === selectedBoardId);
9789
if (selectedBoard && selectedBoard.archived) {
9890
dispatch(boardIdSelected({ boardId: 'none' }));
99-
didReset = true;
91+
dispatch(galleryViewChanged('images'));
10092
}
10193

10294
// Handle the case where auto-add board is archived
10395
const autoAddBoard = queryResult.data.find((b) => b.board_id === autoAddBoardId);
10496
if (autoAddBoard && autoAddBoard.archived) {
10597
dispatch(autoAddBoardIdChanged('none'));
106-
didReset = true;
107-
}
108-
109-
// When resetting the auto-add board or selected board, we should also reset the view to images
110-
if (didReset) {
111-
dispatch(galleryViewChanged('images'));
11298
}
11399
},
114100
});
@@ -123,25 +109,15 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
123109
const state = getState();
124110
const { selectedBoardId, autoAddBoardId } = state.gallery;
125111

126-
let didReset = false;
127-
128112
// Handle the case where selected board isn't in the list of boards
129-
const selectedBoard = boards.find((b) => b.board_id === selectedBoardId);
130-
if (selectedBoard && selectedBoard.archived) {
113+
if (!boards.find((b) => b.board_id === selectedBoardId)) {
131114
dispatch(boardIdSelected({ boardId: 'none' }));
132-
didReset = true;
115+
dispatch(galleryViewChanged('images'));
133116
}
134117

135118
// Handle the case where auto-add board isn't in the list of boards
136-
const autoAddBoard = boards.find((b) => b.board_id === autoAddBoardId);
137-
if (autoAddBoard && autoAddBoard.archived) {
119+
if (!boards.find((b) => b.board_id === autoAddBoardId)) {
138120
dispatch(autoAddBoardIdChanged('none'));
139-
didReset = true;
140-
}
141-
142-
// When resetting the auto-add board or selected board, we should also reset the view to images
143-
if (didReset) {
144-
dispatch(galleryViewChanged('images'));
145121
}
146122
},
147123
});

0 commit comments

Comments
 (0)