remove unused refs from list/grid components

This commit is contained in:
jeffvli
2025-12-08 22:00:34 -08:00
parent 628b0184de
commit a19a6815e9
24 changed files with 1563 additions and 1703 deletions
@@ -1,5 +1,4 @@
import { UseSuspenseQueryOptions } from '@tanstack/react-query';
import { forwardRef } from 'react';
import { api } from '/@/renderer/api';
import { useItemListPaginatedLoader } from '/@/renderer/components/item-list/helpers/item-list-paginated-loader';
@@ -20,70 +19,64 @@ import { ItemListKey } from '/@/shared/types/types';
interface PlaylistListPaginatedGridProps extends ItemListGridComponentProps<PlaylistListQuery> {}
export const PlaylistListPaginatedGrid = forwardRef<any, PlaylistListPaginatedGridProps>(
(
{
gap = 'md',
itemsPerPage = 100,
itemsPerRow,
query = {
sortBy: PlaylistListSort.NAME,
sortOrder: SortOrder.ASC,
},
saveScrollOffset = true,
serverId,
},
ref,
) => {
const listCountQuery = playlistsQueries.listCount({
query: { ...query },
serverId: serverId,
}) as UseSuspenseQueryOptions<number, Error, number, readonly unknown[]>;
const listQueryFn = api.controller.getPlaylistList;
const { currentPage, onChange } = useItemListPagination();
const { data, pageCount, totalItemCount } = useItemListPaginatedLoader({
currentPage,
eventKey: ItemListKey.PLAYLIST,
itemsPerPage,
itemType: LibraryItem.PLAYLIST,
listCountQuery,
listQueryFn,
query,
serverId,
});
const { handleOnScrollEnd, scrollOffset } = useItemListScrollPersist({
enabled: saveScrollOffset,
});
const rows = useGridRows(LibraryItem.PLAYLIST, ItemListKey.PLAYLIST);
return (
<ItemListWithPagination
currentPage={currentPage}
itemsPerPage={itemsPerPage}
onChange={onChange}
pageCount={pageCount}
totalItemCount={totalItemCount}
>
<ItemGridList
currentPage={currentPage}
data={data || []}
gap={gap}
initialTop={{
to: scrollOffset ?? 0,
type: 'offset',
}}
itemsPerRow={itemsPerRow}
itemType={LibraryItem.PLAYLIST}
onScrollEnd={handleOnScrollEnd}
ref={ref}
rows={rows}
/>
</ItemListWithPagination>
);
export const PlaylistListPaginatedGrid = ({
gap = 'md',
itemsPerPage = 100,
itemsPerRow,
query = {
sortBy: PlaylistListSort.NAME,
sortOrder: SortOrder.ASC,
},
);
saveScrollOffset = true,
serverId,
}: PlaylistListPaginatedGridProps) => {
const listCountQuery = playlistsQueries.listCount({
query: { ...query },
serverId: serverId,
}) as UseSuspenseQueryOptions<number, Error, number, readonly unknown[]>;
const listQueryFn = api.controller.getPlaylistList;
const { currentPage, onChange } = useItemListPagination();
const { data, pageCount, totalItemCount } = useItemListPaginatedLoader({
currentPage,
eventKey: ItemListKey.PLAYLIST,
itemsPerPage,
itemType: LibraryItem.PLAYLIST,
listCountQuery,
listQueryFn,
query,
serverId,
});
const { handleOnScrollEnd, scrollOffset } = useItemListScrollPersist({
enabled: saveScrollOffset,
});
const rows = useGridRows(LibraryItem.PLAYLIST, ItemListKey.PLAYLIST);
return (
<ItemListWithPagination
currentPage={currentPage}
itemsPerPage={itemsPerPage}
onChange={onChange}
pageCount={pageCount}
totalItemCount={totalItemCount}
>
<ItemGridList
currentPage={currentPage}
data={data || []}
gap={gap}
initialTop={{
to: scrollOffset ?? 0,
type: 'offset',
}}
itemsPerRow={itemsPerRow}
itemType={LibraryItem.PLAYLIST}
onScrollEnd={handleOnScrollEnd}
rows={rows}
/>
</ItemListWithPagination>
);
};