diff --git a/src/renderer/features/playlists/components/playlist-query-builder.tsx b/src/renderer/features/playlists/components/playlist-query-builder.tsx index 34276b47..613ad2a4 100644 --- a/src/renderer/features/playlists/components/playlist-query-builder.tsx +++ b/src/renderer/features/playlists/components/playlist-query-builder.tsx @@ -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, ) => { 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: { diff --git a/src/renderer/features/playlists/routes/playlist-detail-song-list-route.tsx b/src/renderer/features/playlists/routes/playlist-detail-song-list-route.tsx index eb55407f..730647c9 100644 --- a/src/renderer/features/playlists/routes/playlist-detail-song-list-route.tsx +++ b/src/renderer/features/playlists/routes/playlist-detail-song-list-route.tsx @@ -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'}