mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): select a board when it is created
This commit is contained in:
parent
060d698a12
commit
6014382c7b
@ -15,8 +15,6 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
|
|||||||
matcher: isAnyOf(
|
matcher: isAnyOf(
|
||||||
// Updating a board may change its archived status
|
// Updating a board may change its archived status
|
||||||
boardsApi.endpoints.updateBoard.matchFulfilled,
|
boardsApi.endpoints.updateBoard.matchFulfilled,
|
||||||
// If the selected/auto-add board was deleted from a different session, we'll only know during the list request,
|
|
||||||
boardsApi.endpoints.listAllBoards.matchFulfilled,
|
|
||||||
// If a board is deleted, we'll need to reset the auto-add board
|
// If a board is deleted, we'll need to reset the auto-add board
|
||||||
imagesApi.endpoints.deleteBoard.matchFulfilled,
|
imagesApi.endpoints.deleteBoard.matchFulfilled,
|
||||||
imagesApi.endpoints.deleteBoardAndImages.matchFulfilled,
|
imagesApi.endpoints.deleteBoardAndImages.matchFulfilled,
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { IconButton } from '@invoke-ai/ui-library';
|
import { IconButton } from '@invoke-ai/ui-library';
|
||||||
|
import { useAppDispatch } from 'app/store/storeHooks';
|
||||||
|
import { boardIdSelected } from 'features/gallery/store/gallerySlice';
|
||||||
import { memo, useCallback } from 'react';
|
import { memo, useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { PiPlusBold } from 'react-icons/pi';
|
import { PiPlusBold } from 'react-icons/pi';
|
||||||
@ -10,11 +12,17 @@ type Props = {
|
|||||||
|
|
||||||
const AddBoardButton = ({ isPrivateBoard }: Props) => {
|
const AddBoardButton = ({ isPrivateBoard }: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
const [createBoard, { isLoading }] = useCreateBoardMutation();
|
const [createBoard, { isLoading }] = useCreateBoardMutation();
|
||||||
const DEFAULT_BOARD_NAME = t('boards.myBoard');
|
const DEFAULT_BOARD_NAME = t('boards.myBoard');
|
||||||
const handleCreateBoard = useCallback(() => {
|
const handleCreateBoard = useCallback(async () => {
|
||||||
createBoard({ board_name: DEFAULT_BOARD_NAME, is_private: isPrivateBoard });
|
try {
|
||||||
}, [createBoard, DEFAULT_BOARD_NAME, isPrivateBoard]);
|
const board = await createBoard({ board_name: DEFAULT_BOARD_NAME, is_private: isPrivateBoard }).unwrap();
|
||||||
|
dispatch(boardIdSelected({ boardId: board.board_id }));
|
||||||
|
} catch {
|
||||||
|
//no-op
|
||||||
|
}
|
||||||
|
}, [createBoard, DEFAULT_BOARD_NAME, isPrivateBoard, dispatch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
|
Loading…
Reference in New Issue
Block a user