From 0e5000564325d55197cd51a104cc1333ff71a12f Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Sat, 1 Jul 2023 18:23:24 +1000 Subject: [PATCH] fix(ui): show skeletons only for currently loading images --- .../components/ImageGalleryContent.tsx | 66 +++++++++---------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx b/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx index fce99f64e6..5052782266 100644 --- a/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx @@ -64,6 +64,9 @@ import { boardsSelector } from '../store/boardSlice'; import { ChevronUpIcon } from '@chakra-ui/icons'; import { useListAllBoardsQuery } from 'services/api/endpoints/boards'; import { mode } from 'theme/util/mode'; +import { ImageDTO } from 'services/api/types'; + +const LOADING_IMAGE_ARRAY = Array(20).fill('loading'); const itemSelector = createSelector( [(state: RootState) => state], @@ -79,10 +82,10 @@ const itemSelector = createSelector( ? i.board_id === selectedBoardId : true; return isInCategory && isInSelectedBoard; - }); + }) as (ImageDTO | string)[]; return { - images, + images: isLoading ? images.concat(LOADING_IMAGE_ARRAY) : images, allImagesTotal, isLoading, categories, @@ -356,24 +359,28 @@ const ImageGalleryContent = () => { - {isLoading ? ( - - ) : images.length || areMoreAvailable ? ( + {images.length || areMoreAvailable ? ( <> {shouldUseSingleGalleryColumn ? ( setScrollerRef(ref)} itemContent={(index, item) => ( - + {typeof item === 'string' ? ( + + ) : ( + + )} )} /> @@ -388,11 +395,19 @@ const ImageGalleryContent = () => { }} scrollerRef={setScroller} itemContent={(index, item) => ( - + + {typeof item === 'string' ? ( + + ) : ( + + )} + )} /> )} @@ -445,25 +460,6 @@ const ListContainer = forwardRef((props: ListContainerProps, ref) => { ); }); -const LoadingGallery = () => { - return ( - - ( - - - - )} - /> - - ); -}; const EmptyGallery = () => { const { t } = useTranslation(); return (