Smarter play button, disabled for unplayable tracks
This commit is contained in:
parent
97eab8e8de
commit
a83328bc27
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="['ui', {'tiny': discrete}, 'buttons']">
|
<div :class="['ui', {'tiny': discrete}, 'buttons']">
|
||||||
<button title="Add to current queue" @click="add" :class="['ui', {'mini': discrete}, 'button']">
|
<button title="Add to current queue" @click="add" :class="['ui', {'mini': discrete}, {disabled: playableTracks.length === 0}, 'button']">
|
||||||
<i class="ui play icon"></i>
|
<i class="ui play icon"></i>
|
||||||
<template v-if="!discrete"><slot>Play</slot></template>
|
<template v-if="!discrete"><slot>Play</slot></template>
|
||||||
</button>
|
</button>
|
||||||
|
@ -36,20 +36,25 @@ export default {
|
||||||
jQuery(this.$el).find('.ui.dropdown').dropdown()
|
jQuery(this.$el).find('.ui.dropdown').dropdown()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
computed: {
|
||||||
add () {
|
playableTracks () {
|
||||||
|
let tracks
|
||||||
if (this.track) {
|
if (this.track) {
|
||||||
this.$store.dispatch('queue/append', {track: this.track})
|
tracks = [this.track]
|
||||||
} else {
|
} else {
|
||||||
this.$store.dispatch('queue/appendMany', {tracks: this.tracks})
|
tracks = this.tracks
|
||||||
|
}
|
||||||
|
return tracks.filter(e => {
|
||||||
|
return e.files.length > 0
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
add () {
|
||||||
|
this.$store.dispatch('queue/appendMany', {tracks: this.playableTracks})
|
||||||
|
},
|
||||||
addNext (next) {
|
addNext (next) {
|
||||||
if (this.track) {
|
this.$store.dispatch('queue/appendMany', {tracks: this.playableTracks, index: this.$store.state.queue.currentIndex + 1})
|
||||||
this.$store.dispatch('queue/append', {track: this.track, index: this.$store.state.queue.currentIndex + 1})
|
|
||||||
} else {
|
|
||||||
this.$store.dispatch('queue/appendMany', {tracks: this.tracks, index: this.$store.state.queue.currentIndex + 1})
|
|
||||||
}
|
|
||||||
if (next) {
|
if (next) {
|
||||||
this.$store.dispatch('queue/next')
|
this.$store.dispatch('queue/next')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue