[bugfix]: fix smart playlist, do not error when trying to edit playlist as non-admin

This commit is contained in:
Kendall Garner 2024-03-31 19:34:33 -07:00
parent 44fcc33825
commit 6bc778fa53
No known key found for this signature in database
GPG key ID: 18D2767419676C87
3 changed files with 14 additions and 12 deletions

View file

@ -1,6 +1,6 @@
import { ndApiClient } from '/@/renderer/api/navidrome/navidrome-api'; import { ndApiClient } from '/@/renderer/api/navidrome/navidrome-api';
import { ndNormalize } from '/@/renderer/api/navidrome/navidrome-normalize'; import { ndNormalize } from '/@/renderer/api/navidrome/navidrome-normalize';
import { NavidromeExtensions, ndType } from '/@/renderer/api/navidrome/navidrome-types'; import { ndType } from '/@/renderer/api/navidrome/navidrome-types';
import { ssApiClient } from '/@/renderer/api/subsonic/subsonic-api'; import { ssApiClient } from '/@/renderer/api/subsonic/subsonic-api';
import semverCoerce from 'semver/functions/coerce'; import semverCoerce from 'semver/functions/coerce';
import semverGte from 'semver/functions/gte'; import semverGte from 'semver/functions/gte';
@ -541,7 +541,7 @@ const getServerInfo = async (args: ServerInfoArgs): Promise<ServerInfo> => {
const features: ServerFeatures = { const features: ServerFeatures = {
lyricsMultipleStructured: !!navidromeFeatures[SubsonicExtensions.SONG_LYRICS], lyricsMultipleStructured: !!navidromeFeatures[SubsonicExtensions.SONG_LYRICS],
playlistsSmart: !!navidromeFeatures[NavidromeExtensions.SMART_PLAYLISTS], playlistsSmart: !!navidromeFeatures[ServerFeature.PLAYLISTS_SMART],
}; };
return { features, id: apiClientProps.server?.id, version: ping.body.serverVersion! }; return { features, id: apiClientProps.server?.id, version: ping.body.serverVersion! };

View file

@ -343,10 +343,6 @@ const removeFromPlaylistParameters = z.object({
id: z.array(z.string()), id: z.array(z.string()),
}); });
export enum NavidromeExtensions {
SMART_PLAYLISTS = 'smartPlaylists',
}
export const ndType = { export const ndType = {
_enum: { _enum: {
albumArtistList: ndAlbumArtistListSort, albumArtistList: ndAlbumArtistListSort,

View file

@ -76,7 +76,7 @@ export const UpdatePlaylistForm = ({ users, query, body, onCancel }: UpdatePlayl
}); });
const isPublicDisplayed = server?.type === ServerType.NAVIDROME; const isPublicDisplayed = server?.type === ServerType.NAVIDROME;
const isOwnerDisplayed = server?.type === ServerType.NAVIDROME; const isOwnerDisplayed = server?.type === ServerType.NAVIDROME && userList;
const isSubmitDisabled = !form.values.name || mutation.isLoading; const isSubmitDisabled = !form.values.name || mutation.isLoading;
return ( return (
@ -154,11 +154,17 @@ export const openUpdatePlaylistModal = async (args: {
const users = const users =
server?.type === ServerType.NAVIDROME server?.type === ServerType.NAVIDROME
? await queryClient.fetchQuery({ ? await queryClient
queryFn: ({ signal }) => .fetchQuery({
api.controller.getUserList({ apiClientProps: { server, signal }, query }), queryFn: ({ signal }) =>
queryKey: queryKeys.users.list(server?.id || '', query), api.controller.getUserList({ apiClientProps: { server, signal }, query }),
}) queryKey: queryKeys.users.list(server?.id || '', query),
})
.catch((error) => {
// This eror most likely happens if the user is not an admin
console.error(error);
return null;
})
: null; : null;
openModal({ openModal({