Keep playlist store separate

This commit is contained in:
jeffvli 2023-03-05 18:47:24 -08:00
parent f21c9010ac
commit 157ac9f3a2
5 changed files with 7 additions and 6 deletions

View file

@ -27,6 +27,7 @@ export const TablePagination = ({
tableRef, tableRef,
pagination, pagination,
setPagination, setPagination,
setIdPagination,
}: TablePaginationProps) => { }: TablePaginationProps) => {
const [isGoToPageOpen, handlers] = useDisclosure(false); const [isGoToPageOpen, handlers] = useDisclosure(false);
const containerQuery = useContainerQuery(); const containerQuery = useContainerQuery();
@ -41,6 +42,7 @@ export const TablePagination = ({
const newPage = index - 1; const newPage = index - 1;
tableRef.current?.api.paginationGoToPage(newPage); tableRef.current?.api.paginationGoToPage(newPage);
setPagination?.({ data: { currentPage: newPage }, key: pageKey }); setPagination?.({ data: { currentPage: newPage }, key: pageKey });
setIdPagination?.(pageKey || '', { currentPage: newPage });
}; };
const handleGoSubmit = goToForm.onSubmit((values) => { const handleGoSubmit = goToForm.onSubmit((values) => {
@ -52,6 +54,7 @@ export const TablePagination = ({
const newPage = values.pageNumber - 1; const newPage = values.pageNumber - 1;
tableRef.current?.api.paginationGoToPage(newPage); tableRef.current?.api.paginationGoToPage(newPage);
setPagination?.({ data: { currentPage: newPage }, key: pageKey }); setPagination?.({ data: { currentPage: newPage }, key: pageKey });
setIdPagination?.(pageKey || '', { currentPage: newPage });
}); });
const currentPageStartIndex = pagination.currentPage * pagination.itemsPerPage + 1; const currentPageStartIndex = pagination.currentPage * pagination.itemsPerPage + 1;

View file

@ -252,7 +252,7 @@ export const PlaylistDetailSongListContent = ({ tableRef }: PlaylistDetailConten
> >
{page.display === ListDisplayType.TABLE_PAGINATED && ( {page.display === ListDisplayType.TABLE_PAGINATED && (
<TablePagination <TablePagination
id={playlistId} pageKey={playlistId}
pagination={pagination} pagination={pagination}
setIdPagination={setPagination} setIdPagination={setPagination}
tableRef={tableRef} tableRef={tableRef}

View file

@ -2,5 +2,6 @@ export * from './auth.store';
export * from './player.store'; export * from './player.store';
export * from './app.store'; export * from './app.store';
export * from './list.store'; export * from './list.store';
export * from './playlist.store';
export * from './album-list-data.store'; export * from './album-list-data.store';
export * from './album-artist-list-data.store'; export * from './album-artist-list-data.store';

View file

@ -8,7 +8,6 @@ import {
AlbumArtistListSort, AlbumArtistListSort,
AlbumListArgs, AlbumListArgs,
AlbumListSort, AlbumListSort,
PlaylistListArgs,
PlaylistListSort, PlaylistListSort,
SongListArgs, SongListArgs,
SongListSort, SongListSort,
@ -24,11 +23,10 @@ export const generatePageKey = (page: string, id?: string) => {
export type AlbumListFilter = Omit<AlbumListArgs['query'], 'startIndex' | 'limit'>; export type AlbumListFilter = Omit<AlbumListArgs['query'], 'startIndex' | 'limit'>;
export type SongListFilter = Omit<SongListArgs['query'], 'startIndex' | 'limit'>; export type SongListFilter = Omit<SongListArgs['query'], 'startIndex' | 'limit'>;
export type AlbumArtistListFilter = Omit<AlbumArtistListArgs['query'], 'startIndex' | 'limit'>; export type AlbumArtistListFilter = Omit<AlbumArtistListArgs['query'], 'startIndex' | 'limit'>;
export type PlaylistListFilter = Omit<PlaylistListArgs['query'], 'startIndex' | 'limit'>;
export type ListKey = keyof ListState['item'] | string; export type ListKey = keyof ListState['item'] | string;
type FilterType = AlbumListFilter | SongListFilter | AlbumArtistListFilter | PlaylistListFilter; type FilterType = AlbumListFilter | SongListFilter | AlbumArtistListFilter;
type ListTableProps = { type ListTableProps = {
pagination: TablePagination; pagination: TablePagination;
@ -55,7 +53,6 @@ export interface ListState {
album: ItemProps<AlbumListFilter>; album: ItemProps<AlbumListFilter>;
albumArtist: ItemProps<AlbumArtistListFilter>; albumArtist: ItemProps<AlbumArtistListFilter>;
albumDetail: ItemProps<any>; albumDetail: ItemProps<any>;
playlist: ItemProps<PlaylistListFilter>;
song: ItemProps<SongListFilter>; song: ItemProps<SongListFilter>;
}; };
} }

View file

@ -3,8 +3,8 @@ import create from 'zustand';
import { devtools, persist } from 'zustand/middleware'; import { devtools, persist } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer'; import { immer } from 'zustand/middleware/immer';
import { PlaylistListArgs, PlaylistListSort, SortOrder } from '/@/renderer/api/types'; import { PlaylistListArgs, PlaylistListSort, SortOrder } from '/@/renderer/api/types';
import { SongListFilter } from '/@/renderer/store/list.store';
import { DataTableProps } from '/@/renderer/store/settings.store'; import { DataTableProps } from '/@/renderer/store/settings.store';
import { SongListFilter } from '/@/renderer/store/song.store';
import { ListDisplayType, TableColumn, TablePagination } from '/@/renderer/types'; import { ListDisplayType, TableColumn, TablePagination } from '/@/renderer/types';
type TableProps = { type TableProps = {