[web-src] Do not rely on name of playlist for podcast deletion

This commit is contained in:
chme 2020-04-18 13:29:10 +02:00
parent 4b1688ceb8
commit f2d4b88c12
3 changed files with 22 additions and 16 deletions

View File

@ -130,15 +130,14 @@ export default {
open_remove_podcast_dialog: function () {
this.show_album_details_modal = false
webapi.search({ type: 'playlist', query: this.album.name }).then(({ data }) => {
var playlists = data.playlists.items.filter(pl => pl.name === this.album.name && pl.type === 'rss')
if (playlists.length !== 1) {
webapi.library_track_playlists(this.tracks[0].id).then(({ data }) => {
const rssPlaylists = data.items.filter(pl => pl.type === 'rss')
if (rssPlaylists.length !== 1) {
this.$store.dispatch('add_notification', { text: 'Podcast cannot be removed. Probably it was not added as an RSS playlist.', type: 'danger' })
return
}
this.rss_playlist_to_remove = playlists[0]
this.rss_playlist_to_remove = rssPlaylists[0]
this.show_remove_podcast_modal = true
})
},

View File

@ -167,16 +167,17 @@ export default {
open_remove_podcast_dialog: function () {
this.show_album_details_modal = false
webapi.search({ type: 'playlist', query: this.selected_album.name }).then(({ data }) => {
var playlists = data.playlists.items.filter(pl => pl.name === this.selected_album.name && pl.type === 'rss')
webapi.library_album_tracks(this.selected_album.id, { limit: 1 }).then(({ data }) => {
webapi.library_track_playlists(data.items[0].id).then(({ data }) => {
const rssPlaylists = data.items.filter(pl => pl.type === 'rss')
if (rssPlaylists.length !== 1) {
this.$store.dispatch('add_notification', { text: 'Podcast cannot be removed. Probably it was not added as an RSS playlist.', type: 'danger' })
return
}
if (playlists.length !== 1) {
this.$store.dispatch('add_notification', { text: 'Podcast cannot be removed. Probably it was not added as an RSS playlist.', type: 'danger' })
return
}
this.rss_playlist_to_remove = playlists[0]
this.show_remove_podcast_modal = true
this.rss_playlist_to_remove = rssPlaylists[0]
this.show_remove_podcast_modal = true
})
})
},

View File

@ -217,8 +217,10 @@ export default {
return axios.get('/api/library/albums/' + albumId)
},
library_album_tracks (albumId) {
return axios.get('/api/library/albums/' + albumId + '/tracks')
library_album_tracks (albumId, filter = { limit: -1, offset: 0 }) {
return axios.get('/api/library/albums/' + albumId + '/tracks', {
params: filter
})
},
library_album_track_update (albumId, attributes) {
@ -319,6 +321,10 @@ export default {
return axios.get('/api/library/tracks/' + trackId)
},
library_track_playlists (trackId) {
return axios.get('/api/library/tracks/' + trackId + '/playlists')
},
library_track_update (trackId, attributes = {}) {
return axios.put('/api/library/tracks/' + trackId, undefined, { params: attributes })
},