2022-12-28 01:44:49 -08:00
|
|
|
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
|
2025-05-18 14:03:18 -07:00
|
|
|
|
2023-06-02 13:09:28 -07:00
|
|
|
import { lazy, MutableRefObject, Suspense } from 'react';
|
2025-05-18 14:03:18 -07:00
|
|
|
|
2023-06-02 13:09:28 -07:00
|
|
|
import { Spinner } from '/@/renderer/components';
|
|
|
|
|
import { VirtualInfiniteGridRef } from '/@/renderer/components/virtual-grid';
|
2023-07-20 00:34:07 -07:00
|
|
|
import { useListContext } from '/@/renderer/context/list-context';
|
|
|
|
|
import { useListStoreByKey } from '/@/renderer/store';
|
2025-05-20 19:23:36 -07:00
|
|
|
import { ListDisplayType } from '/@/shared/types/types';
|
2023-06-02 13:09:28 -07:00
|
|
|
|
|
|
|
|
const AlbumListGridView = lazy(() =>
|
2023-07-01 19:10:05 -07:00
|
|
|
import('/@/renderer/features/albums/components/album-list-grid-view').then((module) => ({
|
|
|
|
|
default: module.AlbumListGridView,
|
|
|
|
|
})),
|
2023-06-02 13:09:28 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const AlbumListTableView = lazy(() =>
|
2023-07-01 19:10:05 -07:00
|
|
|
import('/@/renderer/features/albums/components/album-list-table-view').then((module) => ({
|
|
|
|
|
default: module.AlbumListTableView,
|
|
|
|
|
})),
|
2023-06-02 13:09:28 -07:00
|
|
|
);
|
2022-12-24 14:07:58 -08:00
|
|
|
|
2022-12-24 20:20:17 -08:00
|
|
|
interface AlbumListContentProps {
|
2025-05-18 14:03:18 -07:00
|
|
|
gridRef: MutableRefObject<null | VirtualInfiniteGridRef>;
|
2023-07-01 19:10:05 -07:00
|
|
|
itemCount?: number;
|
|
|
|
|
tableRef: MutableRefObject<AgGridReactType | null>;
|
2022-12-24 20:20:17 -08:00
|
|
|
}
|
|
|
|
|
|
2025-05-18 14:03:18 -07:00
|
|
|
export const AlbumListContent = ({ gridRef, itemCount, tableRef }: AlbumListContentProps) => {
|
2023-07-20 00:34:07 -07:00
|
|
|
const { pageKey } = useListContext();
|
|
|
|
|
const { display } = useListStoreByKey({ key: pageKey });
|
2023-01-08 00:52:53 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return (
|
|
|
|
|
<Suspense fallback={<Spinner container />}>
|
|
|
|
|
{display === ListDisplayType.CARD || display === ListDisplayType.POSTER ? (
|
|
|
|
|
<AlbumListGridView
|
|
|
|
|
gridRef={gridRef}
|
|
|
|
|
itemCount={itemCount}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<AlbumListTableView
|
|
|
|
|
itemCount={itemCount}
|
|
|
|
|
tableRef={tableRef}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</Suspense>
|
|
|
|
|
);
|
2022-12-24 14:07:58 -08:00
|
|
|
};
|