From a7a5b92011a35397193da95df90c5e3caffbb5f5 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Tue, 5 Mar 2024 14:12:37 -0800 Subject: [PATCH] Adjust server feature naming convention --- src/renderer/api/features-types.ts | 8 +++++--- src/renderer/api/jellyfin/jellyfin-controller.ts | 2 +- src/renderer/api/navidrome/navidrome-controller.ts | 8 ++++---- src/renderer/api/subsonic/subsonic-controller.ts | 2 +- src/renderer/features/lyrics/queries/lyric-query.ts | 4 ++-- .../playlists/components/create-playlist-form.tsx | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/renderer/api/features-types.ts b/src/renderer/api/features-types.ts index 631ec5ff..779c846e 100644 --- a/src/renderer/api/features-types.ts +++ b/src/renderer/api/features-types.ts @@ -1,7 +1,9 @@ +// Should follow a strict naming convention: "_" +// For example: : "Playlists", : "Smart" = "PLAYLISTS_SMART" export enum ServerFeature { - MULTIPLE_STRUCTURED_LYRICS = 'multipleStructuredLyrics', - SINGLE_STRUCTURED_LYRIC = 'singleStructuredLyric', - SMART_PLAYLISTS = 'smartPlaylists', + LYRICS_MULTIPLE_STRUCTURED = 'lyricsMultipleStructured', + LYRICS_SINGLE_STRUCTURED = 'lyricsSingleStructured', + PLAYLISTS_SMART = 'playlistsSmart', } export type ServerFeatures = Partial>; diff --git a/src/renderer/api/jellyfin/jellyfin-controller.ts b/src/renderer/api/jellyfin/jellyfin-controller.ts index 8adcd3df..31082b03 100644 --- a/src/renderer/api/jellyfin/jellyfin-controller.ts +++ b/src/renderer/api/jellyfin/jellyfin-controller.ts @@ -961,7 +961,7 @@ const getServerInfo = async (args: ServerInfoArgs): Promise => { } const features: ServerFeatures = { - singleStructuredLyric: true, + lyricsSingleStructured: true, }; return { diff --git a/src/renderer/api/navidrome/navidrome-controller.ts b/src/renderer/api/navidrome/navidrome-controller.ts index dd18d523..33eb367a 100644 --- a/src/renderer/api/navidrome/navidrome-controller.ts +++ b/src/renderer/api/navidrome/navidrome-controller.ts @@ -368,7 +368,7 @@ const getPlaylistList = async (args: PlaylistListArgs): Promise]> = [ - ['0.48.0', { [ServerFeature.SMART_PLAYLISTS]: [1] }], + ['0.48.0', { [ServerFeature.PLAYLISTS_SMART]: [1] }], ]; const getFeatures = (version: string): Record => { @@ -540,8 +540,8 @@ const getServerInfo = async (args: ServerInfoArgs): Promise => { } const features: ServerFeatures = { - multipleStructuredLyrics: !!navidromeFeatures[SubsonicExtensions.SONG_LYRICS], - smartPlaylists: !!navidromeFeatures[NavidromeExtensions.SMART_PLAYLISTS], + lyricsMultipleStructured: !!navidromeFeatures[SubsonicExtensions.SONG_LYRICS], + playlistsSmart: !!navidromeFeatures[NavidromeExtensions.SMART_PLAYLISTS], }; return { features, id: apiClientProps.server?.id, version: ping.body.serverVersion! }; diff --git a/src/renderer/api/subsonic/subsonic-controller.ts b/src/renderer/api/subsonic/subsonic-controller.ts index c968c200..66301beb 100644 --- a/src/renderer/api/subsonic/subsonic-controller.ts +++ b/src/renderer/api/subsonic/subsonic-controller.ts @@ -404,7 +404,7 @@ const getServerInfo = async (args: ServerInfoArgs): Promise => { } if (subsonicFeatures[SubsonicExtensions.SONG_LYRICS]) { - features.multipleStructuredLyrics = true; + features.lyricsMultipleStructured = true; } return { features, id: apiClientProps.server?.id, version: ping.body.serverVersion }; diff --git a/src/renderer/features/lyrics/queries/lyric-query.ts b/src/renderer/features/lyrics/queries/lyric-query.ts index c8511dba..c19d2438 100644 --- a/src/renderer/features/lyrics/queries/lyric-query.ts +++ b/src/renderer/features/lyrics/queries/lyric-query.ts @@ -96,7 +96,7 @@ export const useSongLyricsBySong = ( if (!server) throw new Error('Server not found'); if (!song) return null; - if (hasFeature(server, ServerFeature.MULTIPLE_STRUCTURED_LYRICS)) { + if (hasFeature(server, ServerFeature.LYRICS_MULTIPLE_STRUCTURED)) { const subsonicLyrics = await api.controller .getStructuredLyrics({ apiClientProps: { server, signal }, @@ -107,7 +107,7 @@ export const useSongLyricsBySong = ( if (subsonicLyrics) { return subsonicLyrics; } - } else if (hasFeature(server, ServerFeature.SINGLE_STRUCTURED_LYRIC)) { + } else if (hasFeature(server, ServerFeature.LYRICS_SINGLE_STRUCTURED)) { const jfLyrics = await api.controller .getLyrics({ apiClientProps: { server, signal }, diff --git a/src/renderer/features/playlists/components/create-playlist-form.tsx b/src/renderer/features/playlists/components/create-playlist-form.tsx index ef5a116d..12fbbe08 100644 --- a/src/renderer/features/playlists/components/create-playlist-form.tsx +++ b/src/renderer/features/playlists/components/create-playlist-form.tsx @@ -123,7 +123,7 @@ export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => { /> )} {server?.type === ServerType.NAVIDROME && - hasFeature(server, ServerFeature.SMART_PLAYLISTS) && ( + hasFeature(server, ServerFeature.PLAYLISTS_SMART) && ( setIsSmartPlaylist(e.currentTarget.checked)}