add functionality to play button on artist page

This commit is contained in:
geoffrey45
2022-12-06 23:29:14 +03:00
committed by Mungai Njoroge
parent bb95011dff
commit 90dd1a1fe8
12 changed files with 145 additions and 43 deletions
+25 -8
View File
@@ -2,16 +2,24 @@ import { playSources } from "@/composables/enums";
import useAStore from "@/stores/pages/album";
import useFStore from "@/stores/pages/folder";
import usePStore from "@/stores/pages/playlist";
import useArtistPageStore from "@/stores/pages/artist";
import { getArtistTracks } from "./fetch/artists";
import useQStore from "@/stores/queue";
const queue = useQStore;
const folder = useFStore;
const album = useAStore;
const playlist = usePStore;
const artist = useArtistPageStore;
type store = typeof queue | typeof folder | typeof album | typeof playlist;
type store =
| typeof queue
| typeof folder
| typeof album
| typeof playlist
| typeof artist;
export default function play(
export default async function play(
source: playSources,
aqueue: typeof queue,
store: store
@@ -20,13 +28,13 @@ export default function play(
switch (source) {
// check which route the play request come from
case playSources.folder:
store = store as typeof folder;
const f = store();
// case playSources.folder:
// store = store as typeof folder;
// const f = store();
useQueue.playFromFolder(f.path, f.allTracks);
useQueue.play();
break;
// useQueue.playFromFolder(f.path, f.tracks);
// useQueue.play();
// break;
case playSources.album:
store = store as typeof album;
const a_store = store();
@@ -47,5 +55,14 @@ export default function play(
useQueue.playFromPlaylist(p.info.name, p.info.id, p.tracks);
useQueue.play();
break;
case playSources.artist:
store = store as typeof artist;
const ar = store();
const tracks = await getArtistTracks(ar.info.artisthash);
useQueue.playFromArtist(ar.info.artisthash, ar.info.name, tracks);
useQueue.play();
}
}