fix(volume): restore pre-mute volume on unmute (#48)

Mute now saves the current volume before setting to 0, and unmute
restores it. Pre-mute volume persists in localStorage across sessions.
Centralized toggleMute in playerStore so all UI components (NowPlayingBar,
immersive VolumeSlider) behave consistently. Also moved session volume
persistence into setVolume to avoid duplication.
This commit is contained in:
vicrodh committed 2026-02-05 08:36:56 -06:00
1 parent 348d57e84f
commit 2f5f5ff8a6
4 files changed
+34 -5

No files matched your search

+2 -1
View File
@@ -27,6 +27,7 @@
getOfflineReason,
type OfflineReason
} from '$lib/stores/offlineStore';
import { toggleMute } from '$lib/stores/playerStore';
interface Props {
artwork?: string;
@@ -386,7 +387,7 @@
<div class="volume-value" class:visible={isDraggingVolume}>{volume}</div>
<button
class="control-btn volume-btn"
onclick={() => onVolumeChange?.(volume === 0 ? 70 : 0)}
onclick={() => toggleMute()}
title={volume === 0 ? $t('player.unmute') : $t('player.mute')}
>
{#if volume === 0}
@@ -1,5 +1,6 @@
<script lang="ts">
import { Volume2, VolumeX } from 'lucide-svelte';
import { toggleMute as playerToggleMute } from '$lib/stores/playerStore';
interface Props {
volume: number;
@@ -42,7 +43,7 @@
}
function toggleMute() {
onVolumeChange(volume > 0 ? 0 : 50);
playerToggleMute();
}
</script>