Redo queue handler as hook

This commit is contained in:
jeffvli 2022-12-20 04:11:06 -08:00
parent 3dd9e620a8
commit c858479d57
12 changed files with 247 additions and 199 deletions

View file

@ -5,7 +5,13 @@ import type { FixedSizeListProps } from 'react-window';
import { FixedSizeList } from 'react-window';
import styled from 'styled-components';
import { GridCard } from '/@/renderer/components/virtual-grid/grid-card';
import type { CardRow, LibraryItem, CardDisplayType, CardRoute } from '/@/renderer/types';
import type {
CardRow,
LibraryItem,
CardDisplayType,
CardRoute,
PlayQueueAddOptions,
} from '/@/renderer/types';
const createItemData = memoize(
(
@ -19,10 +25,12 @@ const createItemData = memoize(
itemType,
itemWidth,
route,
handlePlayQueueAdd,
) => ({
cardRows,
columnCount,
display,
handlePlayQueueAdd,
itemCount,
itemData,
itemGap,
@ -47,6 +55,7 @@ export const VirtualGridWrapper = ({
columnCount,
rowCount,
initialScrollOffset,
handlePlayQueueAdd,
itemData,
route,
onScroll,
@ -55,6 +64,7 @@ export const VirtualGridWrapper = ({
cardRows: CardRow[];
columnCount: number;
display: CardDisplayType;
handlePlayQueueAdd?: (options: PlayQueueAddOptions) => void;
itemData: any[];
itemGap: number;
itemHeight: number;
@ -75,6 +85,7 @@ export const VirtualGridWrapper = ({
itemType,
itemWidth,
route,
handlePlayQueueAdd,
);
const memoizedOnScroll = createScrollHandler(onScroll);