Prevent blank screen on grid-view render
- Add loading prop to before rendering to check for itemCount
This commit is contained in:
parent
df4f05b14c
commit
ad3728a55d
3 changed files with 67 additions and 57 deletions
|
@ -21,6 +21,7 @@ interface VirtualGridProps extends Omit<FixedSizeListProps, 'children' | 'itemSi
|
||||||
itemGap: number;
|
itemGap: number;
|
||||||
itemSize: number;
|
itemSize: number;
|
||||||
itemType: LibraryItem;
|
itemType: LibraryItem;
|
||||||
|
loading?: boolean;
|
||||||
minimumBatchSize?: number;
|
minimumBatchSize?: number;
|
||||||
route?: CardRoute;
|
route?: CardRoute;
|
||||||
setItemData: (data: any[]) => void;
|
setItemData: (data: any[]) => void;
|
||||||
|
@ -50,6 +51,7 @@ export const VirtualInfiniteGrid = forwardRef(
|
||||||
handlePlayQueueAdd,
|
handlePlayQueueAdd,
|
||||||
minimumBatchSize,
|
minimumBatchSize,
|
||||||
fetchFn,
|
fetchFn,
|
||||||
|
loading,
|
||||||
initialScrollOffset,
|
initialScrollOffset,
|
||||||
height,
|
height,
|
||||||
width,
|
width,
|
||||||
|
@ -126,7 +128,10 @@ export const VirtualInfiniteGrid = forwardRef(
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (loading) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<InfiniteLoader
|
<InfiniteLoader
|
||||||
ref={loader}
|
ref={loader}
|
||||||
isItemLoaded={(index) => isItemLoaded(index)}
|
isItemLoaded={(index) => isItemLoaded(index)}
|
||||||
|
@ -161,6 +166,7 @@ export const VirtualInfiniteGrid = forwardRef(
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</InfiniteLoader>
|
</InfiniteLoader>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -312,6 +312,7 @@ export const AlbumListContent = ({ gridRef, tableRef }: AlbumListContentProps) =
|
||||||
{page.display === ListDisplayType.CARD || page.display === ListDisplayType.POSTER ? (
|
{page.display === ListDisplayType.CARD || page.display === ListDisplayType.POSTER ? (
|
||||||
<AutoSizer>
|
<AutoSizer>
|
||||||
{({ height, width }) => (
|
{({ height, width }) => (
|
||||||
|
<>
|
||||||
<VirtualInfiniteGrid
|
<VirtualInfiniteGrid
|
||||||
key={`album-list-${server?.id}-${page.display}`}
|
key={`album-list-${server?.id}-${page.display}`}
|
||||||
ref={gridRef}
|
ref={gridRef}
|
||||||
|
@ -326,6 +327,7 @@ export const AlbumListContent = ({ gridRef, tableRef }: AlbumListContentProps) =
|
||||||
itemGap={20}
|
itemGap={20}
|
||||||
itemSize={150 + page.grid?.size}
|
itemSize={150 + page.grid?.size}
|
||||||
itemType={LibraryItem.ALBUM}
|
itemType={LibraryItem.ALBUM}
|
||||||
|
loading={checkAlbumList.isLoading}
|
||||||
minimumBatchSize={40}
|
minimumBatchSize={40}
|
||||||
route={{
|
route={{
|
||||||
route: AppRoute.LIBRARY_ALBUMS_DETAIL,
|
route: AppRoute.LIBRARY_ALBUMS_DETAIL,
|
||||||
|
@ -335,6 +337,7 @@ export const AlbumListContent = ({ gridRef, tableRef }: AlbumListContentProps) =
|
||||||
width={width}
|
width={width}
|
||||||
onScroll={handleGridScroll}
|
onScroll={handleGridScroll}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</AutoSizer>
|
</AutoSizer>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -306,6 +306,7 @@ export const AlbumArtistListContent = ({ gridRef, tableRef }: AlbumArtistListCon
|
||||||
itemGap={20}
|
itemGap={20}
|
||||||
itemSize={150 + page.grid?.size}
|
itemSize={150 + page.grid?.size}
|
||||||
itemType={LibraryItem.ALBUM_ARTIST}
|
itemType={LibraryItem.ALBUM_ARTIST}
|
||||||
|
loading={checkAlbumArtistList.isLoading}
|
||||||
minimumBatchSize={40}
|
minimumBatchSize={40}
|
||||||
route={{
|
route={{
|
||||||
route: AppRoute.LIBRARY_ALBUMARTISTS_DETAIL,
|
route: AppRoute.LIBRARY_ALBUMARTISTS_DETAIL,
|
||||||
|
|
Reference in a new issue