mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 02:13:33 +00:00
fix jellyfin playlists, add is public
This commit is contained in:
parent
528bef01f0
commit
93377dcc4f
11 changed files with 81 additions and 51 deletions
|
|
@ -28,7 +28,6 @@ export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
|
|||
initialValues: {
|
||||
_custom: {
|
||||
navidrome: {
|
||||
public: false,
|
||||
rules: undefined,
|
||||
},
|
||||
},
|
||||
|
|
@ -88,7 +87,7 @@ export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
|
|||
);
|
||||
});
|
||||
|
||||
const isPublicDisplayed = server?.type === ServerType.NAVIDROME;
|
||||
const isPublicDisplayed = hasFeature(server, ServerFeature.PUBLIC_PLAYLIST);
|
||||
const isSubmitDisabled = !form.values.name || mutation.isLoading;
|
||||
|
||||
return (
|
||||
|
|
@ -103,13 +102,15 @@ export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
|
|||
})}
|
||||
{...form.getInputProps('name')}
|
||||
/>
|
||||
<TextInput
|
||||
label={t('form.createPlaylist.input', {
|
||||
context: 'description',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('comment')}
|
||||
/>
|
||||
{server?.type === ServerType.NAVIDROME && (
|
||||
<TextInput
|
||||
label={t('form.createPlaylist.input', {
|
||||
context: 'description',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('comment')}
|
||||
/>
|
||||
)}
|
||||
<Group>
|
||||
{isPublicDisplayed && (
|
||||
<Switch
|
||||
|
|
@ -117,7 +118,7 @@ export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
|
|||
context: 'public',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('_custom.navidrome.public', {
|
||||
{...form.getInputProps('public', {
|
||||
type: 'checkbox',
|
||||
})}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import { Button, Switch, TextInput, toast } from '/@/renderer/components';
|
|||
import { useCreatePlaylist } from '/@/renderer/features/playlists/mutations/create-playlist-mutation';
|
||||
import { useCurrentServer } from '/@/renderer/store';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { ServerFeature } from '/@/renderer/api/features-types';
|
||||
import { hasFeature } from '/@/renderer/api/utils';
|
||||
|
||||
interface SaveAsPlaylistFormProps {
|
||||
body: Partial<CreatePlaylistBody>;
|
||||
|
|
@ -27,13 +29,13 @@ export const SaveAsPlaylistForm = ({
|
|||
initialValues: {
|
||||
_custom: {
|
||||
navidrome: {
|
||||
public: false,
|
||||
rules: undefined,
|
||||
...body?._custom?.navidrome,
|
||||
},
|
||||
},
|
||||
comment: body.comment || '',
|
||||
name: body.name || '',
|
||||
public: body.public,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -58,7 +60,7 @@ export const SaveAsPlaylistForm = ({
|
|||
);
|
||||
});
|
||||
|
||||
const isPublicDisplayed = server?.type === ServerType.NAVIDROME;
|
||||
const isPublicDisplayed = hasFeature(server, ServerFeature.PUBLIC_PLAYLIST);
|
||||
const isSubmitDisabled = !form.values.name || mutation.isLoading;
|
||||
|
||||
return (
|
||||
|
|
@ -73,20 +75,22 @@ export const SaveAsPlaylistForm = ({
|
|||
})}
|
||||
{...form.getInputProps('name')}
|
||||
/>
|
||||
<TextInput
|
||||
label={t('form.createPlaylist.input', {
|
||||
context: 'description',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('comment')}
|
||||
/>
|
||||
{server?.type === ServerType.NAVIDROME && (
|
||||
<TextInput
|
||||
label={t('form.createPlaylist.input', {
|
||||
context: 'description',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('comment')}
|
||||
/>
|
||||
)}
|
||||
{isPublicDisplayed && (
|
||||
<Switch
|
||||
label={t('form.createPlaylist.input', {
|
||||
context: 'public',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('_custom.navidrome.public', { type: 'checkbox' })}
|
||||
{...form.getInputProps('public', { type: 'checkbox' })}
|
||||
/>
|
||||
)}
|
||||
<Group position="right">
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import { queryClient } from '/@/renderer/lib/react-query';
|
|||
import { useCurrentServer } from '/@/renderer/store';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18n from '/@/i18n/i18n';
|
||||
import { hasFeature } from '/@/renderer/api/utils';
|
||||
import { ServerFeature } from '/@/renderer/api/features-types';
|
||||
|
||||
interface UpdatePlaylistFormProps {
|
||||
body: Partial<UpdatePlaylistBody>;
|
||||
|
|
@ -44,13 +46,13 @@ export const UpdatePlaylistForm = ({ users, query, body, onCancel }: UpdatePlayl
|
|||
navidrome: {
|
||||
owner: body?._custom?.navidrome?.owner || '',
|
||||
ownerId: body?._custom?.navidrome?.ownerId || '',
|
||||
public: body?._custom?.navidrome?.public || false,
|
||||
rules: undefined,
|
||||
sync: body?._custom?.navidrome?.sync || false,
|
||||
},
|
||||
},
|
||||
comment: body?.comment || '',
|
||||
name: body?.name || '',
|
||||
public: body.public,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -69,13 +71,16 @@ export const UpdatePlaylistForm = ({ users, query, body, onCancel }: UpdatePlayl
|
|||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
toast.success({
|
||||
message: t('form.editPlaylist.success', { postProcess: 'sentenceCase' }),
|
||||
});
|
||||
onCancel();
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
const isPublicDisplayed = server?.type === ServerType.NAVIDROME;
|
||||
const isPublicDisplayed = hasFeature(server, ServerFeature.PUBLIC_PLAYLIST);
|
||||
const isOwnerDisplayed = server?.type === ServerType.NAVIDROME && userList;
|
||||
const isSubmitDisabled = !form.values.name || mutation.isLoading;
|
||||
|
||||
|
|
@ -91,13 +96,15 @@ export const UpdatePlaylistForm = ({ users, query, body, onCancel }: UpdatePlayl
|
|||
})}
|
||||
{...form.getInputProps('name')}
|
||||
/>
|
||||
<TextInput
|
||||
label={t('form.createPlaylist.input', {
|
||||
context: 'description',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('comment')}
|
||||
/>
|
||||
{server?.type === ServerType.NAVIDROME && (
|
||||
<TextInput
|
||||
label={t('form.createPlaylist.input', {
|
||||
context: 'description',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('comment')}
|
||||
/>
|
||||
)}
|
||||
{isOwnerDisplayed && (
|
||||
<Select
|
||||
data={userList || []}
|
||||
|
|
@ -109,13 +116,22 @@ export const UpdatePlaylistForm = ({ users, query, body, onCancel }: UpdatePlayl
|
|||
/>
|
||||
)}
|
||||
{isPublicDisplayed && (
|
||||
<Switch
|
||||
label={t('form.createPlaylist.input', {
|
||||
context: 'public',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('_custom.navidrome.public', { type: 'checkbox' })}
|
||||
/>
|
||||
<>
|
||||
{server?.type === ServerType.JELLYFIN && (
|
||||
<div>
|
||||
{t('form.editPlaylist.publicJellyfinNote', {
|
||||
postProcess: 'sentenceCase',
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
<Switch
|
||||
label={t('form.createPlaylist.input', {
|
||||
context: 'public',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('public', { type: 'checkbox' })}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<Group position="right">
|
||||
<Button
|
||||
|
|
@ -175,7 +191,6 @@ export const openUpdatePlaylistModal = async (args: {
|
|||
navidrome: {
|
||||
owner: playlist?.owner || undefined,
|
||||
ownerId: playlist?.ownerId || undefined,
|
||||
public: playlist?.public || false,
|
||||
rules: playlist?.rules || undefined,
|
||||
sync: playlist?.sync || undefined,
|
||||
},
|
||||
|
|
@ -183,6 +198,7 @@ export const openUpdatePlaylistModal = async (args: {
|
|||
comment: playlist?.description || undefined,
|
||||
genres: playlist?.genres,
|
||||
name: playlist?.name,
|
||||
public: playlist?.public || false,
|
||||
}}
|
||||
query={{ id: playlist?.id }}
|
||||
users={users?.items}
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ const PlaylistDetailSongListRoute = () => {
|
|||
navidrome: {
|
||||
owner: detailQuery?.data?.owner || '',
|
||||
ownerId: detailQuery?.data?.ownerId || '',
|
||||
public: detailQuery?.data?.public || false,
|
||||
rules,
|
||||
sync: detailQuery?.data?.sync || false,
|
||||
},
|
||||
},
|
||||
comment: detailQuery?.data?.description || '',
|
||||
name: detailQuery?.data?.name,
|
||||
public: detailQuery?.data?.public || false,
|
||||
},
|
||||
serverId: detailQuery?.data?.serverId,
|
||||
},
|
||||
|
|
@ -92,7 +92,6 @@ const PlaylistDetailSongListRoute = () => {
|
|||
navidrome: {
|
||||
owner: detailQuery?.data?.owner || '',
|
||||
ownerId: detailQuery?.data?.ownerId || '',
|
||||
public: detailQuery?.data?.public || false,
|
||||
rules: {
|
||||
...filter,
|
||||
limit: extraFilters.limit || undefined,
|
||||
|
|
@ -104,6 +103,7 @@ const PlaylistDetailSongListRoute = () => {
|
|||
},
|
||||
comment: detailQuery?.data?.description || '',
|
||||
name: detailQuery?.data?.name,
|
||||
public: detailQuery?.data?.public || false,
|
||||
}}
|
||||
serverId={detailQuery?.data?.serverId}
|
||||
onCancel={closeAllModals}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue