mirror of
https://github.com/jeffvli/feishin.git
synced 2024-11-20 06:27:09 +01:00
Adjust server feature naming convention
This commit is contained in:
parent
a9315be259
commit
a7a5b92011
@ -1,7 +1,9 @@
|
||||
// Should follow a strict naming convention: "<FEATURE GROUP>_<FEATURE NAME>"
|
||||
// For example: <FEATURE GROUP>: "Playlists", <FEATURE NAME>: "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<Record<ServerFeature, boolean>>;
|
||||
|
@ -961,7 +961,7 @@ const getServerInfo = async (args: ServerInfoArgs): Promise<ServerInfo> => {
|
||||
}
|
||||
|
||||
const features: ServerFeatures = {
|
||||
singleStructuredLyric: true,
|
||||
lyricsSingleStructured: true,
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -368,7 +368,7 @@ const getPlaylistList = async (args: PlaylistListArgs): Promise<PlaylistListResp
|
||||
if (
|
||||
customQuery &&
|
||||
customQuery.smart !== undefined &&
|
||||
!hasFeature(apiClientProps.server, ServerFeature.SMART_PLAYLISTS)
|
||||
!hasFeature(apiClientProps.server, ServerFeature.PLAYLISTS_SMART)
|
||||
) {
|
||||
customQuery.smart = undefined;
|
||||
}
|
||||
@ -483,7 +483,7 @@ const removeFromPlaylist = async (
|
||||
};
|
||||
|
||||
const VERSION_INFO: Array<[string, Record<string, number[]>]> = [
|
||||
['0.48.0', { [ServerFeature.SMART_PLAYLISTS]: [1] }],
|
||||
['0.48.0', { [ServerFeature.PLAYLISTS_SMART]: [1] }],
|
||||
];
|
||||
|
||||
const getFeatures = (version: string): Record<string, number[]> => {
|
||||
@ -540,8 +540,8 @@ const getServerInfo = async (args: ServerInfoArgs): Promise<ServerInfo> => {
|
||||
}
|
||||
|
||||
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! };
|
||||
|
@ -404,7 +404,7 @@ const getServerInfo = async (args: ServerInfoArgs): Promise<ServerInfo> => {
|
||||
}
|
||||
|
||||
if (subsonicFeatures[SubsonicExtensions.SONG_LYRICS]) {
|
||||
features.multipleStructuredLyrics = true;
|
||||
features.lyricsMultipleStructured = true;
|
||||
}
|
||||
|
||||
return { features, id: apiClientProps.server?.id, version: ping.body.serverVersion };
|
||||
|
@ -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 },
|
||||
|
@ -123,7 +123,7 @@ export const CreatePlaylistForm = ({ onCancel }: CreatePlaylistFormProps) => {
|
||||
/>
|
||||
)}
|
||||
{server?.type === ServerType.NAVIDROME &&
|
||||
hasFeature(server, ServerFeature.SMART_PLAYLISTS) && (
|
||||
hasFeature(server, ServerFeature.PLAYLISTS_SMART) && (
|
||||
<Switch
|
||||
label="Is smart playlist?"
|
||||
onChange={(e) => setIsSmartPlaylist(e.currentTarget.checked)}
|
||||
|
Loading…
Reference in New Issue
Block a user