feat: setup tracklist with rest api

This commit is contained in:
Roberto Tonino
2021-03-12 20:26:45 +01:00
parent b2b85fb84e
commit 1743878a14
5 changed files with 88 additions and 90 deletions

View File

@@ -34602,16 +34602,9 @@ function formatArtistReleases(artistReleases) {
}
function getArtistData(artistID) {
socket.emit('getTracklist', {
return fetchData('getTracklist', {
type: 'artist',
id: artistID
});
return new Promise((resolve, reject) => {
socket.on('show_artist', data => {
socket.off('show_artist');
resolve(data);
});
})
}
@@ -36296,7 +36289,6 @@ async function refreshFavorites({ isInitial = false }) {
const spotifyPlaylists = await fetchData('getUserSpotifyPlaylists', {
spotifyUser: store.getters.getSpotifyUser.id
});
console.log({ spotifyPlaylists });
favoriteSpotifyPlaylists.value = spotifyPlaylists;
}
}
@@ -45530,9 +45522,9 @@ var script$t = {
}
},
mounted() {
socket.on('show_album', this.showAlbum);
socket.on('show_playlist', this.showPlaylist);
socket.on('show_spotifyplaylist', this.showSpotifyPlaylist);
EventBus.$on('showAlbum', this.showAlbum);
EventBus.$on('showPlaylist', this.showPlaylist);
EventBus.$on('showSpotifyPlaylist', this.showSpotifyPlaylist);
},
methods: {
playPausePreview,
@@ -45551,17 +45543,17 @@ var script$t = {
},
toggleAll(e) {
this.body.forEach(item => {
if (item.type == 'track') {
if (item.type === 'track') {
item.selected = e.currentTarget.checked;
}
});
},
selectedLinks() {
var selected = [];
const selected = [];
if (this.body) {
this.body.forEach(item => {
if (item.type == 'track' && item.selected)
selected.push(this.type == 'spotifyPlaylist' ? item.uri : item.link);
if (item.type === 'track' && item.selected)
selected.push(this.type === 'spotifyPlaylist' ? item.uri : item.link);
});
}
return selected.join(';')
@@ -45875,11 +45867,11 @@ var __vue_render__$v = function() {
staticClass:
"table__cell--medium table__cell--center clickable",
attrs: {
tag: "td",
to: {
name: "Artist",
params: { id: track.artist.id }
}
},
tag: "td"
}
},
[
@@ -45898,11 +45890,11 @@ var __vue_render__$v = function() {
staticClass:
"table__cell--medium table__cell--center clickable",
attrs: {
tag: "td",
to: {
name: "Album",
params: { id: track.album.id }
}
},
tag: "td"
}
},
[
@@ -46375,38 +46367,45 @@ const router = new VueRouter({
});
router.beforeEach((to, from, next) => {
let getTracklistParams = null;
switch (to.name) {
case 'Tracklist':
getTracklistParams = {
type: to.params.type,
id: to.params.id
};
case 'Tracklist': {
// const getTracklistParams = {
// type: to.params.type,
// id: to.params.id
// }
console.warn('This should never happen.');
break
case 'Album':
getTracklistParams = {
}
case 'Album': {
const getTracklistParams = {
type: 'album',
id: to.params.id
};
fetchData('getTracklist', getTracklistParams).then(albumData => {
EventBus.$emit('showAlbum', albumData);
});
break
case 'Playlist':
getTracklistParams = {
}
case 'Playlist': {
const getTracklistParams = {
type: 'playlist',
id: to.params.id
};
fetchData('getTracklist', getTracklistParams).then(playlistData => {
EventBus.$emit('showPlaylist', playlistData);
});
break
case 'Spotify Playlist':
getTracklistParams = {
}
case 'Spotify Playlist': {
const getTracklistParams = {
type: 'spotifyplaylist',
id: to.params.id
};
fetchData('getTracklist', getTracklistParams).then(spotifyPlaylistData => {
EventBus.$emit('showSpotifyPlaylist', spotifyPlaylistData);
});
break
}
if (getTracklistParams) {
socket.emit('getTracklist', getTracklistParams);
fetchData('getTracklist', getTracklistParams);
}
}
next();