add favourite button to player

This commit is contained in:
Thomas Amland
2021-05-13 13:00:38 +02:00
parent 3636635b23
commit 4312a4899b
4 changed files with 27 additions and 2 deletions
+10
View File
@@ -41,6 +41,11 @@
<div class="col-auto col-sm p-0">
<div class="d-flex flex-nowrap justify-content-end pr-3">
<div class="m-0 d-none d-md-inline-flex align-items-center">
<b-button title="Favourite"
variant="link" class="m-0"
@click="toggleFavourite">
<Icon :icon="track.favourite ? 'heart-fill' : 'heart'" />
</b-button>
<b-button id="player-volume-btn" variant="link" title="Volume">
<Icon :icon="muteActive ? 'volume-mute-fill' : 'volume-up-fill'" />
</b-button>
@@ -160,6 +165,11 @@
setVolume(volume: any) {
return this.$store.dispatch('player/setVolume', parseFloat(volume))
},
toggleFavourite() {
return this.track.favourite
? this.$store.dispatch('removeFavourite', this.track.id)
: this.$store.dispatch('addFavourite', this.track.id)
}
}
})
</script>
+7
View File
@@ -133,6 +133,13 @@ export const playerModule: Module<State, any> = {
state.mute = value <= 0.0
localStorage.setItem('player.volume', String(value))
},
updateTrack(state, track) {
const idx = state.queue.findIndex(x => x.id === track.id)
if (idx > -1) {
state.queue[idx] = Object.assign(state.queue[idx], track)
persistQueue(state)
}
},
},
actions: {