diff --git a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardsList.tsx b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardsList.tsx index 3ea76a3729..d5a96e5966 100644 --- a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardsList.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardsList.tsx @@ -1,9 +1,8 @@ import { Button, Collapse, Flex, Icon, Text, useDisclosure } from '@invoke-ai/ui-library'; import { EMPTY_ARRAY } from 'app/store/constants'; import { useAppSelector } from 'app/store/storeHooks'; -import DeleteBoardModal from 'features/gallery/components/Boards/DeleteBoardModal'; import { selectListBoardsQueryArgs } from 'features/gallery/store/gallerySelectors'; -import { useMemo, useState } from 'react'; +import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { PiCaretDownBold } from 'react-icons/pi'; import { useListAllBoardsQuery } from 'services/api/endpoints/boards'; @@ -15,15 +14,15 @@ import NoBoardBoard from './NoBoardBoard'; type Props = { isPrivate: boolean; + setBoardToDelete: (board?: BoardDTO) => void; }; -export const BoardsList = ({ isPrivate }: Props) => { +export const BoardsList = ({ isPrivate, setBoardToDelete }: Props) => { const { t } = useTranslation(); const selectedBoardId = useAppSelector((s) => s.gallery.selectedBoardId); const boardSearchText = useAppSelector((s) => s.gallery.boardSearchText); const queryArgs = useAppSelector(selectListBoardsQueryArgs); const { data: boards } = useListAllBoardsQuery(queryArgs); - const [boardToDelete, setBoardToDelete] = useState(); const allowPrivateBoards = useAppSelector((s) => s.config.allowPrivateBoards); const { isOpen, onToggle } = useDisclosure({ defaultIsOpen: true }); @@ -63,7 +62,7 @@ export const BoardsList = ({ isPrivate }: Props) => { }); return elements; - }, [filteredBoards, isPrivate, allowPrivateBoards, boardSearchText, selectedBoardId]); + }, [allowPrivateBoards, isPrivate, boardSearchText.length, filteredBoards, selectedBoardId, setBoardToDelete]); const boardListTitle = useMemo(() => { if (allowPrivateBoards) { @@ -74,53 +73,50 @@ export const BoardsList = ({ isPrivate }: Props) => { }, [isPrivate, allowPrivateBoards, t]); return ( - <> - - - {allowPrivateBoards ? ( - + + + {allowPrivateBoards ? ( + + ) : ( + + {boardListTitle} + + )} + + + + + {boardElements.length ? ( + boardElements ) : ( - - {boardListTitle} + + {t('boards.noBoards', { boardType: boardSearchText.length ? 'Matching' : '' })} )} - - - - {boardElements.length ? ( - boardElements - ) : ( - - {t('boards.noBoards', { boardType: boardSearchText.length ? 'Matching' : '' })} - - )} - - - - - + + ); }; diff --git a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardsListWrapper.tsx b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardsListWrapper.tsx index 9e7806c484..637dbd304a 100644 --- a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardsListWrapper.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardsListWrapper.tsx @@ -1,9 +1,11 @@ import { Box } from '@invoke-ai/ui-library'; import { useAppSelector } from 'app/store/storeHooks'; import { overlayScrollbarsParams } from 'common/components/OverlayScrollbars/constants'; +import DeleteBoardModal from 'features/gallery/components/Boards/DeleteBoardModal'; import { OverlayScrollbarsComponent } from 'overlayscrollbars-react'; import type { CSSProperties } from 'react'; -import { memo } from 'react'; +import { memo, useState } from 'react'; +import type { BoardDTO } from 'services/api/types'; import { BoardsList } from './BoardsList'; @@ -14,16 +16,20 @@ const overlayScrollbarsStyles: CSSProperties = { const BoardsListWrapper = () => { const allowPrivateBoards = useAppSelector((s) => s.config.allowPrivateBoards); + const [boardToDelete, setBoardToDelete] = useState(); return ( - - - - {allowPrivateBoards && } - - + <> + + + + {allowPrivateBoards && } + + + - + + ); }; export default memo(BoardsListWrapper);