From baedced83f0cbdabc848827783d803211f7defee Mon Sep 17 00:00:00 2001 From: Zibbp Date: Thu, 8 Sep 2022 10:02:40 -0500 Subject: [PATCH] feat(player): persist volume in local storage --- client/components/controls/VolumeControl.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/components/controls/VolumeControl.vue b/client/components/controls/VolumeControl.vue index b748f653..7212357b 100644 --- a/client/components/controls/VolumeControl.vue +++ b/client/components/controls/VolumeControl.vue @@ -37,6 +37,11 @@ export default { return this.value }, set(val) { + try { + localStorage.setItem("volume", val); + } catch(error) { + console.error('Failed to store volume', err) + } this.$emit('input', val) } }, @@ -141,6 +146,10 @@ export default { if (this.value === 0) { this.isMute = true } + const storageVolume = localStorage.getItem("volume") + if (storageVolume) { + this.volume = parseFloat(storageVolume) + } }, beforeDestroy() { window.removeEventListener('mousewheel', this.scroll)