Update querykeys
This commit is contained in:
parent
88f53c17db
commit
d6936634db
1 changed files with 30 additions and 9 deletions
|
@ -5,27 +5,38 @@ import type {
|
||||||
AlbumArtistListQuery,
|
AlbumArtistListQuery,
|
||||||
ArtistListQuery,
|
ArtistListQuery,
|
||||||
PlaylistListQuery,
|
PlaylistListQuery,
|
||||||
|
PlaylistDetailQuery,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
export const queryKeys = {
|
export const queryKeys = {
|
||||||
albumArtists: {
|
albumArtists: {
|
||||||
list: (serverId: string, query?: AlbumArtistListQuery) =>
|
detail: (serverId: string, query?: AlbumArtistListQuery) => {
|
||||||
[serverId, 'albumArtists', 'list', query] as const,
|
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;
|
||||||
|
},
|
||||||
root: (serverId: string) => [serverId, 'albumArtists'] as const,
|
root: (serverId: string) => [serverId, 'albumArtists'] as const,
|
||||||
},
|
},
|
||||||
albums: {
|
albums: {
|
||||||
detail: (serverId: string, query?: AlbumDetailQuery) =>
|
detail: (serverId: string, query?: AlbumDetailQuery) =>
|
||||||
[serverId, 'albums', 'detail', query] as const,
|
[serverId, 'albums', 'detail', query] as const,
|
||||||
list: (serverId: string, query?: AlbumListQuery) =>
|
list: (serverId: string, query?: AlbumListQuery) => {
|
||||||
[serverId, 'albums', 'list', query] as const,
|
if (query) return [serverId, 'albums', 'list', query] as const;
|
||||||
|
return [serverId, 'albums', 'list'] as const;
|
||||||
|
},
|
||||||
root: (serverId: string) => [serverId, 'albums'],
|
root: (serverId: string) => [serverId, 'albums'],
|
||||||
serverRoot: (serverId: string) => [serverId, 'albums'],
|
serverRoot: (serverId: string) => [serverId, 'albums'],
|
||||||
songs: (serverId: string, query: SongListQuery) =>
|
songs: (serverId: string, query: SongListQuery) =>
|
||||||
[serverId, 'albums', 'songs', query] as const,
|
[serverId, 'albums', 'songs', query] as const,
|
||||||
},
|
},
|
||||||
artists: {
|
artists: {
|
||||||
list: (serverId: string, query?: ArtistListQuery) =>
|
list: (serverId: string, query?: ArtistListQuery) => {
|
||||||
[serverId, 'artists', 'list', query] as const,
|
if (query) return [serverId, 'artists', 'list', query] as const;
|
||||||
|
return [serverId, 'artists', 'list'] as const;
|
||||||
|
},
|
||||||
root: (serverId: string) => [serverId, 'artists'] as const,
|
root: (serverId: string) => [serverId, 'artists'] as const,
|
||||||
},
|
},
|
||||||
genres: {
|
genres: {
|
||||||
|
@ -36,15 +47,25 @@ export const queryKeys = {
|
||||||
list: (serverId: string) => [serverId, 'musicFolders', 'list'] as const,
|
list: (serverId: string) => [serverId, 'musicFolders', 'list'] as const,
|
||||||
},
|
},
|
||||||
playlists: {
|
playlists: {
|
||||||
list: (serverId: string, query?: PlaylistListQuery) =>
|
detail: (serverId: string, id?: string, query?: PlaylistDetailQuery) => {
|
||||||
[serverId, 'playlists', 'list', query] as const,
|
if (query) return [serverId, 'playlists', 'detail', id, query] as const;
|
||||||
|
if (id) return [serverId, 'playlists', 'detail', id] as const;
|
||||||
|
return [serverId, 'playlists', 'detail'] as const;
|
||||||
|
},
|
||||||
|
list: (serverId: string, query?: PlaylistListQuery) => {
|
||||||
|
if (query) return [serverId, 'playlists', 'list', query] as const;
|
||||||
|
return [serverId, 'playlists', 'list'] as const;
|
||||||
|
},
|
||||||
root: (serverId: string) => [serverId, 'playlists'] as const,
|
root: (serverId: string) => [serverId, 'playlists'] as const,
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
root: (serverId: string) => [serverId] as const,
|
root: (serverId: string) => [serverId] as const,
|
||||||
},
|
},
|
||||||
songs: {
|
songs: {
|
||||||
list: (serverId: string, query?: SongListQuery) => [serverId, 'songs', 'list', query] as const,
|
list: (serverId: string, query?: SongListQuery) => {
|
||||||
|
if (query) return [serverId, 'songs', 'list', query] as const;
|
||||||
|
return [serverId, 'songs', 'list'] as const;
|
||||||
|
},
|
||||||
root: (serverId: string) => [serverId, 'songs'] as const,
|
root: (serverId: string) => [serverId, 'songs'] as const,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue