feishin/src/renderer/api/query-keys.ts

83 lines
3.2 KiB
TypeScript
Raw Normal View History

2022-12-30 21:04:06 -08:00
import type {
AlbumListQuery,
SongListQuery,
AlbumDetailQuery,
AlbumArtistListQuery,
ArtistListQuery,
2022-12-31 03:46:12 -08:00
PlaylistListQuery,
2022-12-31 12:43:32 -08:00
PlaylistDetailQuery,
2022-12-31 18:03:26 -08:00
PlaylistSongListQuery,
2022-12-30 21:04:06 -08:00
} from './types';
2022-12-19 15:59:14 -08:00
export const queryKeys = {
2022-12-30 21:04:06 -08:00
albumArtists: {
2022-12-31 12:43:32 -08:00
detail: (serverId: string, query?: AlbumArtistListQuery) => {
if (query) return [serverId, 'albumArtists', 'detail', query] as const;
return [serverId, 'albumArtists', 'detail'] as const;
},
list: (serverId: string, query?: AlbumArtistListQuery) => {
if (query) return [serverId, 'albumArtists', 'list', query] as const;
return [serverId, 'albumArtists', 'list'] as const;
},
2022-12-30 21:04:06 -08:00
root: (serverId: string) => [serverId, 'albumArtists'] as const,
},
2022-12-19 15:59:14 -08:00
albums: {
2022-12-30 21:04:06 -08:00
detail: (serverId: string, query?: AlbumDetailQuery) =>
2022-12-19 15:59:14 -08:00
[serverId, 'albums', 'detail', query] as const,
2022-12-31 12:43:32 -08:00
list: (serverId: string, query?: AlbumListQuery) => {
if (query) return [serverId, 'albums', 'list', query] as const;
return [serverId, 'albums', 'list'] as const;
},
2022-12-30 21:04:06 -08:00
root: (serverId: string) => [serverId, 'albums'],
2022-12-19 15:59:14 -08:00
serverRoot: (serverId: string) => [serverId, 'albums'],
songs: (serverId: string, query: SongListQuery) =>
[serverId, 'albums', 'songs', query] as const,
},
2022-12-30 21:04:06 -08:00
artists: {
2022-12-31 12:43:32 -08:00
list: (serverId: string, query?: ArtistListQuery) => {
if (query) return [serverId, 'artists', 'list', query] as const;
return [serverId, 'artists', 'list'] as const;
},
2022-12-30 21:04:06 -08:00
root: (serverId: string) => [serverId, 'artists'] as const,
},
2022-12-19 15:59:14 -08:00
genres: {
list: (serverId: string) => [serverId, 'genres', 'list'] as const,
root: (serverId: string) => [serverId, 'genres'] as const,
},
2022-12-20 19:11:33 -08:00
musicFolders: {
list: (serverId: string) => [serverId, 'musicFolders', 'list'] as const,
},
2022-12-31 03:46:12 -08:00
playlists: {
2022-12-31 12:43:32 -08:00
detail: (serverId: string, id?: string, query?: PlaylistDetailQuery) => {
2022-12-31 18:03:26 -08:00
if (query) return [serverId, 'playlists', id, 'detail', query] as const;
if (id) return [serverId, 'playlists', id, 'detail'] as const;
2022-12-31 12:43:32 -08:00
return [serverId, 'playlists', 'detail'] as const;
},
2023-01-02 02:04:23 -08:00
detailSongList: (serverId: string, id: string, query?: PlaylistSongListQuery) => {
if (query) return [serverId, 'playlists', id, 'detailSongList', query] as const;
if (id) return [serverId, 'playlists', id, 'detailSongList'] as const;
return [serverId, 'playlists', 'detailSongList'] as const;
},
2022-12-31 12:43:32 -08:00
list: (serverId: string, query?: PlaylistListQuery) => {
if (query) return [serverId, 'playlists', 'list', query] as const;
return [serverId, 'playlists', 'list'] as const;
},
2022-12-31 03:46:12 -08:00
root: (serverId: string) => [serverId, 'playlists'] as const,
2022-12-31 18:03:26 -08:00
songList: (serverId: string, id: string, query?: PlaylistSongListQuery) => {
if (query) return [serverId, 'playlists', id, 'songList', query] as const;
if (id) return [serverId, 'playlists', id, 'songList'] as const;
return [serverId, 'playlists', 'songList'] as const;
},
2022-12-31 03:46:12 -08:00
},
2022-12-19 15:59:14 -08:00
server: {
root: (serverId: string) => [serverId] as const,
},
songs: {
2022-12-31 12:43:32 -08:00
list: (serverId: string, query?: SongListQuery) => {
if (query) return [serverId, 'songs', 'list', query] as const;
return [serverId, 'songs', 'list'] as const;
},
2022-12-30 21:04:06 -08:00
root: (serverId: string) => [serverId, 'songs'] as const,
2022-12-19 15:59:14 -08:00
},
};