fix fetching playlists and creating options

This commit is contained in:
geoffrey45 2022-03-26 12:37:34 +03:00
parent 6c997c8795
commit ed4725a279

View File

@ -1,4 +1,4 @@
import { Track } from "../interfaces"; import { Playlist, Track } from "../interfaces";
import Router from "../router"; import Router from "../router";
import { Option } from "../interfaces"; import { Option } from "../interfaces";
import { getAllPlaylists } from "../composables/playlists"; import { getAllPlaylists } from "../composables/playlists";
@ -10,9 +10,22 @@ import { getAllPlaylists } from "../composables/playlists";
* @return {Array<Option>()} a list of context menu items. * @return {Array<Option>()} a list of context menu items.
*/ */
export default (track: Track, modalStore: any) => { export default async (track: Track, modalStore: any): Promise<Option[]> => {
const single_artist = track.artists.length === 1; const single_artist = track.artists.length === 1;
let playlists = <Option[]>[];
const p = await getAllPlaylists();
playlists = p.map((playlist: Playlist) => {
return <Option>{
label: playlist.name,
action: () => {
console.log(playlist.name);
},
};
});
const goToArtist = () => { const goToArtist = () => {
if (single_artist) { if (single_artist) {
return false; return false;
@ -26,18 +39,7 @@ export default (track: Track, modalStore: any) => {
}); });
}; };
async function addToPlaylist() { function addToPlaylist() {
const p = await getAllPlaylists();
const playlists = p.map((playlist) => {
return <Option>{
label: playlist.name,
action: () => {
console.log("playlist");
},
};
});
const new_playlist = <Option>{ const new_playlist = <Option>{
label: "New playlist", label: "New playlist",
action: () => { action: () => {