mirror of
https://github.com/jeffvli/feishin.git
synced 2024-11-20 06:27:09 +01:00
Filter out current playlist on playlist operators
This commit is contained in:
parent
ce0c07ebdb
commit
683bb0222c
@ -57,6 +57,7 @@ interface PlaylistQueryBuilderProps {
|
||||
parsedFilter: any,
|
||||
extraFilters: { limit?: number; sortBy?: string; sortOrder?: string },
|
||||
) => void;
|
||||
playlistId?: string;
|
||||
query: any;
|
||||
sortBy: SongListSort;
|
||||
sortOrder: 'asc' | 'desc';
|
||||
@ -89,7 +90,16 @@ export type PlaylistQueryBuilderRef = {
|
||||
|
||||
export const PlaylistQueryBuilder = forwardRef(
|
||||
(
|
||||
{ sortOrder, sortBy, limit, isSaving, query, onSave, onSaveAs }: PlaylistQueryBuilderProps,
|
||||
{
|
||||
sortOrder,
|
||||
sortBy,
|
||||
limit,
|
||||
isSaving,
|
||||
query,
|
||||
onSave,
|
||||
onSaveAs,
|
||||
playlistId,
|
||||
}: PlaylistQueryBuilderProps,
|
||||
ref: Ref<PlaylistQueryBuilderRef>,
|
||||
) => {
|
||||
const { t } = useTranslation();
|
||||
@ -105,11 +115,17 @@ export const PlaylistQueryBuilder = forwardRef(
|
||||
|
||||
const playlistData = useMemo(() => {
|
||||
if (!playlists) return [];
|
||||
return playlists.items.map((p) => ({
|
||||
label: p.name,
|
||||
value: p.id,
|
||||
}));
|
||||
}, [playlists]);
|
||||
|
||||
return playlists.items
|
||||
.filter((p) => {
|
||||
if (!playlistId) return true;
|
||||
return p.id !== playlistId;
|
||||
})
|
||||
.map((p) => ({
|
||||
label: p.name,
|
||||
value: p.id,
|
||||
}));
|
||||
}, [playlistId, playlists]);
|
||||
|
||||
const extraFiltersForm = useForm({
|
||||
initialValues: {
|
||||
|
@ -196,6 +196,7 @@ const PlaylistDetailSongListRoute = () => {
|
||||
key={JSON.stringify(detailQuery?.data?.rules)}
|
||||
isSaving={createPlaylistMutation?.isLoading}
|
||||
limit={detailQuery?.data?.rules?.limit}
|
||||
playlistId={playlistId}
|
||||
query={detailQuery?.data?.rules}
|
||||
sortBy={detailQuery?.data?.rules?.sort || SongListSort.ALBUM}
|
||||
sortOrder={detailQuery?.data?.rules?.order || 'asc'}
|
||||
|
Loading…
Reference in New Issue
Block a user