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

View File

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

View File

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

View File

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

View File

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

View File

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