[client] add playlists and playlist page

This commit is contained in:
geoffrey45
2022-03-29 00:35:39 +03:00
parent e4640d9985
commit 69b691284d
15 changed files with 217 additions and 47 deletions
+37 -1
View File
@@ -74,4 +74,40 @@ async function addTrackToPlaylist(playlist: Playlist, track: Track) {
});
}
export { createNewPlaylist, getAllPlaylists, addTrackToPlaylist };
async function getPTracks(playlistid: string) {
const uri = state.settings.uri + "/playlist/" + playlistid;
let tracks: Track[] = [];
await axios
.get(uri)
.then((res) => {
tracks = res.data.data;
})
.catch((err) => {
new Notification("Something funny happened!", NotifType.Error);
throw new Error(err);
});
return tracks;
}
async function getPlaylist(pid: string) {
const uri = state.settings.uri + "/playlist/" + pid;
let playlist: Playlist;
await axios
.get(uri)
.then((res) => {
playlist = res.data.data;
})
.catch((err) => {
new Notification("Something funny happened!", NotifType.Error);
throw new Error(err);
});
return playlist;
}
export { createNewPlaylist, getAllPlaylists, addTrackToPlaylist, getPTracks, getPlaylist };