2022-12-30 21:04:06 -08:00
|
|
|
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
|
|
|
|
|
import { useRef } from 'react';
|
2023-04-30 22:01:52 -07:00
|
|
|
import { useCurrentServer } from '../../../store/auth.store';
|
2023-07-19 20:53:49 -07:00
|
|
|
import { useListFilterByKey } from '../../../store/list.store';
|
|
|
|
|
import { LibraryItem } from '/@/renderer/api/types';
|
2023-04-30 22:01:52 -07:00
|
|
|
import { VirtualInfiniteGridRef } from '/@/renderer/components/virtual-grid';
|
2023-07-19 20:53:49 -07:00
|
|
|
import { ListContext } from '/@/renderer/context/list-context';
|
|
|
|
|
import { AlbumArtistListContent } from '/@/renderer/features/artists/components/album-artist-list-content';
|
|
|
|
|
import { AlbumArtistListHeader } from '/@/renderer/features/artists/components/album-artist-list-header';
|
|
|
|
|
import { useAlbumArtistList } from '/@/renderer/features/artists/queries/album-artist-list-query';
|
|
|
|
|
import { AnimatedPage } from '/@/renderer/features/shared';
|
2022-12-30 21:04:06 -08:00
|
|
|
|
|
|
|
|
const AlbumArtistListRoute = () => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const gridRef = useRef<VirtualInfiniteGridRef | null>(null);
|
|
|
|
|
const tableRef = useRef<AgGridReactType | null>(null);
|
2023-07-19 20:53:49 -07:00
|
|
|
const pageKey = LibraryItem.ALBUM_ARTIST;
|
2023-07-01 19:10:05 -07:00
|
|
|
const server = useCurrentServer();
|
2023-03-05 21:02:05 -08:00
|
|
|
|
2023-07-19 20:53:49 -07:00
|
|
|
const albumArtistListFilter = useListFilterByKey({ key: pageKey });
|
2023-01-28 20:46:07 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const itemCountCheck = useAlbumArtistList({
|
|
|
|
|
options: {
|
|
|
|
|
cacheTime: 1000 * 60,
|
|
|
|
|
staleTime: 1000 * 60,
|
|
|
|
|
},
|
|
|
|
|
query: {
|
|
|
|
|
limit: 1,
|
|
|
|
|
startIndex: 0,
|
|
|
|
|
...albumArtistListFilter,
|
|
|
|
|
},
|
|
|
|
|
serverId: server?.id,
|
|
|
|
|
});
|
2023-01-28 20:46:07 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const itemCount =
|
|
|
|
|
itemCountCheck.data?.totalRecordCount === null
|
|
|
|
|
? undefined
|
|
|
|
|
: itemCountCheck.data?.totalRecordCount;
|
2022-12-30 21:04:06 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return (
|
|
|
|
|
<AnimatedPage>
|
2023-07-19 20:53:49 -07:00
|
|
|
<ListContext.Provider value={{ id: undefined, pageKey }}>
|
2023-07-01 19:10:05 -07:00
|
|
|
<AlbumArtistListHeader
|
|
|
|
|
gridRef={gridRef}
|
|
|
|
|
itemCount={itemCount}
|
|
|
|
|
tableRef={tableRef}
|
|
|
|
|
/>
|
|
|
|
|
<AlbumArtistListContent
|
|
|
|
|
gridRef={gridRef}
|
2023-07-16 13:33:23 -07:00
|
|
|
itemCount={itemCount}
|
2023-07-01 19:10:05 -07:00
|
|
|
tableRef={tableRef}
|
|
|
|
|
/>
|
2023-07-19 20:53:49 -07:00
|
|
|
</ListContext.Provider>
|
2023-07-01 19:10:05 -07:00
|
|
|
</AnimatedPage>
|
|
|
|
|
);
|
2022-12-30 21:04:06 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default AlbumArtistListRoute;
|