[web-src] Refactor showing notification after queue add action

This commit is contained in:
chme 2018-12-23 09:54:02 +01:00
parent b0bfa6be60
commit 67af2cc6a9
10 changed files with 30 additions and 58 deletions

View File

@ -76,16 +76,12 @@ export default {
queue_add: function () {
this.$emit('close')
webapi.queue_add(this.album.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add(this.album.uri)
},
queue_add_next: function () {
this.$emit('close')
webapi.queue_add_next(this.album.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add_next(this.album.uri)
},
open_album: function () {

View File

@ -54,16 +54,12 @@ export default {
queue_add: function () {
this.$emit('close')
webapi.queue_add(this.artist.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Artist tracks appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add(this.artist.uri)
},
queue_add_next: function () {
this.$emit('close')
webapi.queue_add_next(this.artist.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add_next(this.artist.uri)
},
open_artist: function () {

View File

@ -47,18 +47,14 @@ export default {
queue_add: function () {
this.$emit('close')
webapi.library_genre(this.genre.name).then(({ data }) =>
webapi.queue_add(data.albums.items.map(a => a.uri).join(',')).then(() =>
this.$store.dispatch('add_notification', { text: 'Genre albums appended to queue', type: 'info', timeout: 1500 })
)
webapi.queue_add(data.albums.items.map(a => a.uri).join(','))
)
},
queue_add_next: function () {
this.$emit('close')
webapi.library_genre(this.genre.name).then(({ data }) =>
webapi.queue_add_next(data.albums.items.map(a => a.uri).join(',')).then(() =>
this.$store.dispatch('add_notification', { text: 'Genre albums playing next', type: 'info', timeout: 1500 })
)
webapi.queue_add_next(data.albums.items.map(a => a.uri).join(','))
)
},

View File

@ -50,16 +50,12 @@ export default {
queue_add: function () {
this.$emit('close')
webapi.queue_add(this.playlist.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Playlist appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add(this.playlist.uri)
},
queue_add_next: function () {
this.$emit('close')
webapi.queue_add_next(this.playlist.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add_next(this.playlist.uri)
},
open_playlist: function () {

View File

@ -99,16 +99,12 @@ export default {
queue_add: function () {
this.$emit('close')
webapi.queue_add(this.track.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Track appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add(this.track.uri)
},
queue_add_next: function () {
this.$emit('close')
webapi.queue_add_next(this.track.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add_next(this.track.uri)
},
open_album: function () {

View File

@ -76,16 +76,12 @@ export default {
queue_add: function () {
this.$emit('close')
webapi.queue_add(this.album.uri).then(
this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 3000 })
)
webapi.queue_add(this.album.uri)
},
queue_add_next: function () {
this.$emit('close')
webapi.queue_add_next(this.album.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add_next(this.album.uri)
},
open_album: function () {

View File

@ -54,16 +54,12 @@ export default {
queue_add: function () {
this.$emit('close')
webapi.queue_add(this.artist.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Artist tracks appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add(this.artist.uri)
},
queue_add_next: function () {
this.$emit('close')
webapi.queue_add_next(this.artist.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Artist tracks appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add_next(this.artist.uri)
},
open_artist: function () {

View File

@ -58,16 +58,12 @@ export default {
queue_add: function () {
this.$emit('close')
webapi.queue_add(this.playlist.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Playlist appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add(this.playlist.uri)
},
queue_add_next: function () {
this.$emit('close')
webapi.queue_add_next(this.playlist.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Playlist tracks appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add_next(this.playlist.uri)
},
open_playlist: function () {

View File

@ -73,16 +73,12 @@ export default {
queue_add: function () {
this.$emit('close')
webapi.queue_add(this.track.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Track appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add(this.track.uri)
},
queue_add_next: function () {
this.$emit('close')
webapi.queue_add_next(this.track.uri).then(() =>
this.$store.dispatch('add_notification', { text: 'Track appended to queue', type: 'info', timeout: 2000 })
)
webapi.queue_add_next(this.track.uri)
},
open_album: function () {

View File

@ -41,8 +41,13 @@ export default {
return axios.put('/api/queue/items/' + itemId + '?new_position=' + newPosition)
},
queue_add (uri) {
return axios.post('/api/queue/items/add?uris=' + uri)
queue_add (uri, showNotification = true) {
return axios.post('/api/queue/items/add?uris=' + uri).then((response) => {
if (showNotification) {
store.dispatch('add_notification', { text: response.data.count + ' tracks appended to queue', type: 'info', timeout: 2000 })
}
return Promise.resolve(response)
})
},
queue_add_next (uri) {
@ -50,7 +55,10 @@ export default {
if (store.getters.now_playing && store.getters.now_playing.id) {
position = store.getters.now_playing.position + 1
}
return axios.post('/api/queue/items/add?uris=' + uri + '&position=' + position)
return axios.post('/api/queue/items/add?uris=' + uri + '&position=' + position).then((response) => {
store.dispatch('add_notification', { text: response.data.count + ' tracks appended to queue', type: 'info', timeout: 2000 })
return Promise.resolve(response)
})
},
player_status () {
@ -60,7 +68,7 @@ export default {
player_play_uri (uris, shuffle, position = undefined) {
return this.queue_clear().then(() =>
this.player_shuffle(shuffle).then(() =>
this.queue_add(uris).then(() =>
this.queue_add(uris, false).then(() =>
this.player_play({ 'position': position })
)
)