mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 10:23:33 +00:00
Handle queue all songs by double click (#67)
This commit is contained in:
parent
93530008a9
commit
51c2731b07
11 changed files with 129 additions and 55 deletions
|
|
@ -12,6 +12,7 @@ import {
|
|||
getSongById,
|
||||
getAlbumSongsById,
|
||||
getAlbumArtistSongsById,
|
||||
getSongsByQuery,
|
||||
} from '/@/renderer/features/player/utils';
|
||||
|
||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||
|
|
@ -44,6 +45,8 @@ export const useHandlePlayQueueAdd = () => {
|
|||
songList = await getAlbumSongsById({ id, query, queryClient, server });
|
||||
} else if (itemType === LibraryItem.ALBUM_ARTIST) {
|
||||
songList = await getAlbumArtistSongsById({ id, query, queryClient, server });
|
||||
} else if (itemType === LibraryItem.SONG) {
|
||||
songList = await getSongsByQuery({ query, queryClient, server });
|
||||
} else {
|
||||
songList = await getSongById({ id: id?.[0], queryClient, server });
|
||||
}
|
||||
|
|
@ -61,8 +64,6 @@ export const useHandlePlayQueueAdd = () => {
|
|||
|
||||
if (!songs) return toast.warn({ message: 'No songs found' });
|
||||
|
||||
// const index = initialIndex || initial songs.findIndex((song) => song.id === initialSongId);
|
||||
|
||||
if (initialIndex) {
|
||||
initialSongIndex = initialIndex;
|
||||
} else if (initialSongId) {
|
||||
|
|
|
|||
|
|
@ -124,6 +124,41 @@ export const getAlbumArtistSongsById = async (args: {
|
|||
return res;
|
||||
};
|
||||
|
||||
export const getSongsByQuery = async (args: {
|
||||
query?: Partial<SongListQuery>;
|
||||
queryClient: QueryClient;
|
||||
server: ServerListItem;
|
||||
}) => {
|
||||
const { queryClient, server, query } = args;
|
||||
|
||||
const queryFilter: SongListQuery = {
|
||||
sortBy: SongListSort.ALBUM,
|
||||
sortOrder: SortOrder.ASC,
|
||||
startIndex: 0,
|
||||
...query,
|
||||
};
|
||||
|
||||
const queryKey = queryKeys.songs.list(server?.id, queryFilter);
|
||||
|
||||
const res = await queryClient.fetchQuery(
|
||||
queryKey,
|
||||
async ({ signal }) =>
|
||||
api.controller.getSongList({
|
||||
apiClientProps: {
|
||||
server,
|
||||
signal,
|
||||
},
|
||||
query: queryFilter,
|
||||
}),
|
||||
{
|
||||
cacheTime: 1000 * 60,
|
||||
staleTime: 1000 * 60,
|
||||
},
|
||||
);
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const getSongById = async (args: {
|
||||
id: string;
|
||||
queryClient: QueryClient;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue