feishin/src/renderer/features/songs/components/song-list-content.tsx

38 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-12-27 13:52:50 -08:00
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
2023-07-16 11:44:33 -07:00
import { lazy, MutableRefObject, Suspense } from 'react';
import { Spinner } from '/@/renderer/components';
2023-03-05 18:28:26 -08:00
import { useSongListContext } from '/@/renderer/features/songs/context/song-list-context';
2023-07-16 11:44:33 -07:00
import { useSongListStore } from '/@/renderer/store';
import { ListDisplayType } from '/@/renderer/types';
const SongListTableView = lazy(() =>
import('/@/renderer/features/songs/components/song-list-table-view').then((module) => ({
default: module.SongListTableView,
})),
);
2022-12-27 13:52:50 -08:00
interface SongListContentProps {
2023-07-01 19:10:05 -07:00
itemCount?: number;
tableRef: MutableRefObject<AgGridReactType | null>;
2022-12-27 13:52:50 -08:00
}
2023-03-05 18:28:26 -08:00
export const SongListContent = ({ itemCount, tableRef }: SongListContentProps) => {
2023-07-16 11:44:33 -07:00
const { id, pageKey } = useSongListContext();
const { display } = useSongListStore({ id, key: pageKey });
2023-07-01 19:10:05 -07:00
2023-07-16 11:44:33 -07:00
const isGrid = display === ListDisplayType.CARD || display === ListDisplayType.POSTER;
2023-07-01 19:10:05 -07:00
return (
2023-07-16 11:44:33 -07:00
<Suspense fallback={<Spinner container />}>
{isGrid ? (
<></>
) : (
<SongListTableView
itemCount={itemCount}
tableRef={tableRef}
2023-07-01 19:10:05 -07:00
/>
2023-07-16 11:44:33 -07:00
)}
</Suspense>
2023-07-01 19:10:05 -07:00
);
2022-12-27 13:52:50 -08:00
};