From 163ef2c941f36778ebcf518c38bda2882cef3f7b Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 15 Jun 2023 14:44:06 +1000 Subject: [PATCH] feat(ui): remove refs to BoardRecord in UI UI should only work w/ BoardDTO --- .../features/gallery/components/HoverableBoard.tsx | 4 ++-- .../gallery/components/ImageGalleryContent.tsx | 12 ++++++------ .../web/src/features/gallery/store/boardSlice.ts | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/invokeai/frontend/web/src/features/gallery/components/HoverableBoard.tsx b/invokeai/frontend/web/src/features/gallery/components/HoverableBoard.tsx index c6762dbe54..dc06fb389b 100644 --- a/invokeai/frontend/web/src/features/gallery/components/HoverableBoard.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/HoverableBoard.tsx @@ -6,7 +6,7 @@ import { ContextMenu } from 'chakra-ui-contextmenu'; import { useTranslation } from 'react-i18next'; import { ExternalLinkIcon } from '@chakra-ui/icons'; import { useAppToaster } from 'app/components/Toaster'; -import { BoardRecord } from 'services/api'; +import { BoardDTO } from 'services/api'; import { EntityId, createSelector } from '@reduxjs/toolkit'; import { selectFilteredImagesIds, @@ -17,7 +17,7 @@ import { defaultSelectorOptions } from '../../../app/store/util/defaultMemoizeOp import { useSelector } from 'react-redux'; interface HoverableBoardProps { - board: BoardRecord; + board: BoardDTO; } /** diff --git a/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx b/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx index a9752d4447..12194095df 100644 --- a/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx @@ -55,8 +55,8 @@ import { } from '../store/imagesSlice'; import { receivedPageOfImages } from 'services/thunks/image'; import { boardSelector } from '../store/boardSelectors'; -import { BoardRecord, ImageDTO } from '../../../services/api'; -import { isBoardRecord, isImageDTO } from '../../../services/types/guards'; +import { BoardDTO, ImageDTO } from '../../../services/api'; +import { isBoardDTO, isImageDTO } from '../../../services/types/guards'; import HoverableBoard from './HoverableBoard'; import IAIInput from '../../../common/components/IAIInput'; import { boardCreated } from '../../../services/thunks/board'; @@ -66,7 +66,7 @@ const itemSelector = createSelector( (state) => { const { images, boards, gallery } = state; - let items: Array = []; + let items: Array = []; let areMoreAvailable = false; let isLoading = true; @@ -78,7 +78,7 @@ const itemSelector = createSelector( areMoreAvailable = items.length < images.total; isLoading = images.isLoading; } else if (gallery.galleryView === 'boards') { - items = Object.values(boards.entities) as BoardRecord[]; + items = Object.values(boards.entities) as BoardDTO[]; areMoreAvailable = items.length < boards.total; isLoading = boards.isLoading; } @@ -365,7 +365,7 @@ const ImageGalleryContent = () => { /> ); - } else if (isBoardRecord(item)) { + } else if (isBoardDTO(item)) { return ( @@ -395,7 +395,7 @@ const ImageGalleryContent = () => { } /> ); - } else if (isBoardRecord(item)) { + } else if (isBoardDTO(item)) { return ( ); diff --git a/invokeai/frontend/web/src/features/gallery/store/boardSlice.ts b/invokeai/frontend/web/src/features/gallery/store/boardSlice.ts index 6b4f1e9431..58457de527 100644 --- a/invokeai/frontend/web/src/features/gallery/store/boardSlice.ts +++ b/invokeai/frontend/web/src/features/gallery/store/boardSlice.ts @@ -5,11 +5,11 @@ import { createSlice, } from '@reduxjs/toolkit'; import { RootState } from 'app/store/store'; -import { BoardRecord } from 'services/api'; +import { BoardDTO } from 'services/api'; import { dateComparator } from 'common/util/dateComparator'; import { receivedBoards } from '../../../services/thunks/board'; -export const boardsAdapter = createEntityAdapter({ +export const boardsAdapter = createEntityAdapter({ selectId: (board) => board.board_id, sortComparer: (a, b) => dateComparator(b.updated_at, a.updated_at), }); @@ -35,10 +35,10 @@ const boardsSlice = createSlice({ name: 'boards', initialState: initialBoardsState, reducers: { - boardUpserted: (state, action: PayloadAction) => { + boardUpserted: (state, action: PayloadAction) => { boardsAdapter.upsertOne(state, action.payload); }, - boardUpdatedOne: (state, action: PayloadAction>) => { + boardUpdatedOne: (state, action: PayloadAction>) => { boardsAdapter.updateOne(state, action.payload); }, boardRemoved: (state, action: PayloadAction) => {