mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 21:10:12 +02:00
move external playback fetch to context
This commit is contained in:
@@ -237,7 +237,6 @@ const EmptyQueueDropZone = () => {
|
||||
const sourceServerId = (
|
||||
args.source.item?.[0] as unknown as { _serverId: string }
|
||||
)?._serverId;
|
||||
|
||||
const sourceItemType = args.source.itemType as LibraryItem;
|
||||
|
||||
switch (args.source.type) {
|
||||
@@ -297,7 +296,7 @@ const EmptyQueueDropZone = () => {
|
||||
const folderIds = folders.map((folder) => folder.id);
|
||||
|
||||
// Handle folders: fetch and add to queue
|
||||
if (folderIds.length > 0) {
|
||||
if (folderIds.length > 0 && sourceServerId) {
|
||||
playerContext.addToQueueByFetch(
|
||||
sourceServerId,
|
||||
folderIds,
|
||||
|
||||
@@ -890,6 +890,9 @@ export const usePlayer = () => {
|
||||
* @param args - The arguments to use to fetch the data
|
||||
* @returns The songs to add to the queue
|
||||
*/
|
||||
|
||||
const EXTERNAL_SERVER_ID = 'musicbrainz';
|
||||
|
||||
export async function fetchSongsByItemType(
|
||||
queryClient: QueryClient,
|
||||
serverId: string,
|
||||
@@ -901,6 +904,23 @@ export async function fetchSongsByItemType(
|
||||
) {
|
||||
const songs: Song[] = [];
|
||||
|
||||
if (serverId === EXTERNAL_SERVER_ID) {
|
||||
if (args.itemType === LibraryItem.ALBUM) {
|
||||
for (const albumId of args.id) {
|
||||
const album = await queryClient.fetchQuery(
|
||||
albumQueries.detail({
|
||||
query: { id: albumId },
|
||||
serverId: EXTERNAL_SERVER_ID,
|
||||
}),
|
||||
);
|
||||
songs.push(...(album?.songs ?? []));
|
||||
}
|
||||
return songs;
|
||||
}
|
||||
|
||||
return songs;
|
||||
}
|
||||
|
||||
switch (args.itemType) {
|
||||
case LibraryItem.ALBUM: {
|
||||
const albumSongsResponse = await getAlbumSongsById({
|
||||
|
||||
Reference in New Issue
Block a user