Skip to content

Commit 6014382

Browse files
feat(ui): select a board when it is created
1 parent 060d698 commit 6014382

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
1515
matcher: isAnyOf(
1616
// Updating a board may change its archived status
1717
boardsApi.endpoints.updateBoard.matchFulfilled,
18-
// If the selected/auto-add board was deleted from a different session, we'll only know during the list request,
19-
boardsApi.endpoints.listAllBoards.matchFulfilled,
2018
// If a board is deleted, we'll need to reset the auto-add board
2119
imagesApi.endpoints.deleteBoard.matchFulfilled,
2220
imagesApi.endpoints.deleteBoardAndImages.matchFulfilled,

invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/AddBoardButton.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { IconButton } from '@invoke-ai/ui-library';
2+
import { useAppDispatch } from 'app/store/storeHooks';
3+
import { boardIdSelected } from 'features/gallery/store/gallerySlice';
24
import { memo, useCallback } from 'react';
35
import { useTranslation } from 'react-i18next';
46
import { PiPlusBold } from 'react-icons/pi';
@@ -10,11 +12,17 @@ type Props = {
1012

1113
const AddBoardButton = ({ isPrivateBoard }: Props) => {
1214
const { t } = useTranslation();
15+
const dispatch = useAppDispatch();
1316
const [createBoard, { isLoading }] = useCreateBoardMutation();
1417
const DEFAULT_BOARD_NAME = t('boards.myBoard');
15-
const handleCreateBoard = useCallback(() => {
16-
createBoard({ board_name: DEFAULT_BOARD_NAME, is_private: isPrivateBoard });
17-
}, [createBoard, DEFAULT_BOARD_NAME, isPrivateBoard]);
18+
const handleCreateBoard = useCallback(async () => {
19+
try {
20+
const board = await createBoard({ board_name: DEFAULT_BOARD_NAME, is_private: isPrivateBoard }).unwrap();
21+
dispatch(boardIdSelected({ boardId: board.board_id }));
22+
} catch {
23+
//no-op
24+
}
25+
}, [createBoard, DEFAULT_BOARD_NAME, isPrivateBoard, dispatch]);
1826

1927
return (
2028
<IconButton

0 commit comments

Comments
 (0)