import { useCallback, useMemo } from 'react'; import { Flex, Group } from '@mantine/core'; import { RiAddBoxFill, RiAddCircleFill, RiPlayFill } from 'react-icons/ri'; import { generatePath } from 'react-router'; import { Link } from 'react-router-dom'; import { LibraryItem } from '/@/renderer/api/types'; import { Button, Text } from '/@/renderer/components'; import { usePlayQueueAdd } from '/@/renderer/features/player'; import { usePlaylistList } from '/@/renderer/features/playlists'; import { AppRoute } from '/@/renderer/router/routes'; import { Play } from '/@/renderer/types'; import AutoSizer from 'react-virtualized-auto-sizer'; import { FixedSizeList, ListChildComponentProps } from 'react-window'; import { useHideScrollbar } from '/@/renderer/hooks'; interface SidebarPlaylistListProps { data: ReturnType['data']; } const PlaylistRow = ({ index, data, style }: ListChildComponentProps) => { return (
{data?.items[index].name}
); }; export const SidebarPlaylistList = ({ data }: SidebarPlaylistListProps) => { const { isScrollbarHidden, hideScrollbarElementProps } = useHideScrollbar(0); const handlePlayQueueAdd = usePlayQueueAdd(); const handlePlayPlaylist = useCallback( (id: string, play: Play) => { handlePlayQueueAdd?.({ byItemType: { id: [id], type: LibraryItem.PLAYLIST, }, play, }); }, [handlePlayQueueAdd], ); const memoizedItemData = useMemo(() => { return { handlePlay: handlePlayPlaylist, items: data?.items, }; }, [data?.items, handlePlayPlaylist]); return ( {({ height, width }) => ( {PlaylistRow} )} ); };