mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
[client] minor refactors
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Playlist, Track } from "../interfaces";
|
||||
import Router from "../router";
|
||||
import { Option } from "../interfaces";
|
||||
import { getAllPlaylists } from "../composables/playlists";
|
||||
import { getAllPlaylists, addTrackToPlaylist } from "../composables/playlists";
|
||||
|
||||
/**
|
||||
* Returns a list of context menu items for a track.
|
||||
@@ -11,17 +11,20 @@ import { getAllPlaylists } from "../composables/playlists";
|
||||
*/
|
||||
|
||||
export default async (track: Track, modalStore: any): Promise<Option[]> => {
|
||||
const separator: Option = {
|
||||
type: "separator",
|
||||
};
|
||||
|
||||
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);
|
||||
addTrackToPlaylist(playlist, track);
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -43,12 +46,11 @@ export default async (track: Track, modalStore: any): Promise<Option[]> => {
|
||||
const new_playlist = <Option>{
|
||||
label: "New playlist",
|
||||
action: () => {
|
||||
modalStore.showModal(modalStore.options.newPlaylist);
|
||||
modalStore.showNewPlaylistModal(track);
|
||||
},
|
||||
};
|
||||
|
||||
console.log([new_playlist, ...playlists]);
|
||||
return [new_playlist, ...playlists];
|
||||
return [new_playlist, separator, ...playlists];
|
||||
}
|
||||
|
||||
const add_to_playlist: Option = {
|
||||
@@ -115,10 +117,6 @@ export default async (track: Track, modalStore: any): Promise<Option[]> => {
|
||||
icon: "heart",
|
||||
};
|
||||
|
||||
const separator: Option = {
|
||||
type: "separator",
|
||||
};
|
||||
|
||||
const options: Option[] = [
|
||||
add_to_playlist,
|
||||
add_to_q,
|
||||
|
||||
Reference in New Issue
Block a user