[web] Add helper methods in stores

This commit is contained in:
Alain Nussbaumer
2025-05-24 09:21:36 +02:00
parent af632f4304
commit 59050c1018
6 changed files with 16 additions and 21 deletions

View File

@@ -8,7 +8,7 @@
<div class="media-content">
<div class="is-size-7 is-uppercase" v-text="$t('navigation.volume')" />
<control-slider
v-model:value="player.volume"
v-model:value="playerStore.volume"
:max="100"
@change="changeVolume"
/>
@@ -26,7 +26,7 @@ export default {
components: { ControlSlider },
setup() {
return {
player: usePlayerStore()
playerStore: usePlayerStore()
}
},
data() {
@@ -36,22 +36,25 @@ export default {
},
computed: {
icon() {
return this.player.volume > 0 ? 'volume-high' : 'volume-off'
if (this.playerStore.isMuted) {
return 'volume-off'
}
return 'volume-high'
}
},
watch: {
'player.volume'() {
if (this.player.volume > 0) {
this.volume = this.player.volume
'playerStore.volume'() {
if (!this.playerStore.isMuted) {
this.volume = this.playerStore.volume
}
}
},
methods: {
changeVolume() {
player.setVolume(this.player.volume)
player.setVolume(this.playerStore.volume)
},
toggle() {
this.player.volume = this.player.volume > 0 ? 0 : this.volume
this.playerStore.volume = this.playerStore.isMuted ? this.volume : 0
this.changeVolume()
}
}

View File

@@ -26,11 +26,7 @@ export default {
},
computed: {
disabled() {
return (
this.queueStore?.count <= 0 ||
this.playerStore.isStopped ||
this.queueStore.current.data_kind === 'pipe'
)
return this.queueStore.isEmpty || this.playerStore.isStopped
},
visible() {
return ['podcast', 'audiobook'].includes(

View File

@@ -26,11 +26,7 @@ export default {
},
computed: {
disabled() {
return (
this.queueStore?.count <= 0 ||
this.playerStore.isStopped ||
this.queueStore.current.data_kind === 'pipe'
)
return this.queueStore.isEmpty || this.playerStore.isStopped
},
visible() {
return ['podcast', 'audiobook'].includes(

View File

@@ -19,7 +19,7 @@ export default {
},
computed: {
disabled() {
return this.queueStore.count <= 0
return this.queueStore.isEmpty
}
},
methods: {

View File

@@ -19,7 +19,7 @@ export default {
},
computed: {
disabled() {
return this.queueStore?.count <= 0
return this.queueStore.isEmpty
},
icon() {
if (!this.playerStore.isPlaying) {

View File

@@ -19,7 +19,7 @@ export default {
},
computed: {
disabled() {
return this.queueStore.count <= 0
return this.queueStore.isEmpty
}
},
methods: {