2025-04-23 23:27:06 -07:00
|
|
|
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
|
2025-05-18 14:03:18 -07:00
|
|
|
|
2025-04-23 23:27:06 -07:00
|
|
|
import { useMemo, useRef } from 'react';
|
2025-05-18 14:03:18 -07:00
|
|
|
|
2025-04-23 23:27:06 -07:00
|
|
|
import { VirtualInfiniteGridRef } from '/@/renderer/components/virtual-grid';
|
|
|
|
|
import { ListContext } from '/@/renderer/context/list-context';
|
|
|
|
|
import { ArtistListContent } from '/@/renderer/features/artists/components/artist-list-content';
|
2025-05-18 14:03:18 -07:00
|
|
|
import { ArtistListHeader } from '/@/renderer/features/artists/components/artist-list-header';
|
|
|
|
|
import { useArtistListCount } from '/@/renderer/features/artists/queries/artist-list-count-query';
|
|
|
|
|
import { AnimatedPage } from '/@/renderer/features/shared';
|
2025-05-20 19:23:36 -07:00
|
|
|
import { useCurrentServer } from '/@/renderer/store/auth.store';
|
|
|
|
|
import { useListFilterByKey } from '/@/renderer/store/list.store';
|
|
|
|
|
import { ArtistListQuery, LibraryItem } from '/@/shared/types/domain-types';
|
2025-04-23 23:27:06 -07:00
|
|
|
|
|
|
|
|
const ArtistListRoute = () => {
|
2025-05-18 14:03:18 -07:00
|
|
|
const gridRef = useRef<null | VirtualInfiniteGridRef>(null);
|
2025-04-23 23:27:06 -07:00
|
|
|
const tableRef = useRef<AgGridReactType | null>(null);
|
|
|
|
|
const pageKey = LibraryItem.ARTIST;
|
|
|
|
|
const server = useCurrentServer();
|
|
|
|
|
|
|
|
|
|
const artistListFilter = useListFilterByKey<ArtistListQuery>({ key: pageKey });
|
|
|
|
|
|
|
|
|
|
const itemCountCheck = useArtistListCount({
|
|
|
|
|
options: {
|
|
|
|
|
cacheTime: 1000 * 60,
|
|
|
|
|
staleTime: 1000 * 60,
|
|
|
|
|
},
|
|
|
|
|
query: artistListFilter,
|
|
|
|
|
serverId: server?.id,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const itemCount = itemCountCheck.data === null ? undefined : itemCountCheck.data;
|
|
|
|
|
|
|
|
|
|
const providerValue = useMemo(() => {
|
|
|
|
|
return {
|
|
|
|
|
id: undefined,
|
|
|
|
|
pageKey,
|
|
|
|
|
};
|
|
|
|
|
}, [pageKey]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<AnimatedPage>
|
|
|
|
|
<ListContext.Provider value={providerValue}>
|
|
|
|
|
<ArtistListHeader
|
|
|
|
|
gridRef={gridRef}
|
|
|
|
|
itemCount={itemCount}
|
|
|
|
|
tableRef={tableRef}
|
|
|
|
|
/>
|
|
|
|
|
<ArtistListContent
|
|
|
|
|
gridRef={gridRef}
|
|
|
|
|
itemCount={itemCount}
|
|
|
|
|
tableRef={tableRef}
|
|
|
|
|
/>
|
|
|
|
|
</ListContext.Provider>
|
|
|
|
|
</AnimatedPage>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ArtistListRoute;
|