Skip to content

Commit 16ae52e

Browse files
committed
Remove unsupported Spotify volume slider
- Replace drawer volume controls with a note about Spotify/system volume - Drop persisted volume state and related store actions
1 parent d655568 commit 16ae52e

2 files changed

Lines changed: 6 additions & 63 deletions

File tree

apps/web/src/components/SpotifyPlayer.tsx

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import {
55
MaximizeIcon,
66
MinimizeIcon,
77
Music2Icon,
8-
Volume1Icon,
9-
Volume2Icon,
10-
VolumeXIcon,
118
XIcon,
129
} from "lucide-react";
1310
import { useCallback, useMemo, useRef, useState } from "react";
@@ -51,51 +48,6 @@ export function SpotifyToggleButton() {
5148
// ---------------------------------------------------------------------------
5249
const CATEGORIES = [...new Set(DEFAULT_PLAYLISTS.map((p) => p.category))];
5350

54-
// ---------------------------------------------------------------------------
55-
// Volume slider — always accessible in the header bar
56-
// ---------------------------------------------------------------------------
57-
function VolumeControl() {
58-
const { volume, setVolume } = useSpotifyPlayerStore();
59-
const [premuteVolume, setPremuteVolume] = useState<number>(80);
60-
61-
const toggleMute = useCallback(() => {
62-
if (volume > 0) {
63-
setPremuteVolume(volume);
64-
setVolume(0);
65-
} else {
66-
setVolume(premuteVolume || 80);
67-
}
68-
}, [volume, premuteVolume, setVolume]);
69-
70-
const VolumeIcon = volume === 0 ? VolumeXIcon : volume < 50 ? Volume1Icon : Volume2Icon;
71-
72-
return (
73-
<div className="flex items-center gap-1.5">
74-
<button
75-
type="button"
76-
onClick={toggleMute}
77-
className="rounded p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground"
78-
aria-label={volume === 0 ? "Unmute" : "Mute"}
79-
>
80-
<VolumeIcon className="size-3.5" />
81-
</button>
82-
<input
83-
type="range"
84-
min={0}
85-
max={100}
86-
step={1}
87-
value={volume}
88-
onChange={(e) => setVolume(Number(e.target.value))}
89-
className="spotify-volume-slider h-1 w-16 cursor-pointer appearance-none rounded-full bg-muted-foreground/20 accent-emerald-400 [&::-webkit-slider-thumb]:size-2.5 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-emerald-400 [&::-webkit-slider-thumb]:transition-transform [&::-webkit-slider-thumb]:hover:scale-125 [&::-moz-range-thumb]:size-2.5 [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-emerald-400"
90-
aria-label="Volume"
91-
/>
92-
<span className="min-w-[2ch] text-[10px] tabular-nums text-muted-foreground/50">
93-
{volume}
94-
</span>
95-
</div>
96-
);
97-
}
98-
9951
// ---------------------------------------------------------------------------
10052
// Main Spotify Player Drawer — rendered at the bottom of ChatView
10153
// ---------------------------------------------------------------------------
@@ -159,8 +111,12 @@ export function SpotifyPlayerDrawer() {
159111
{/* Spacer */}
160112
<div className="flex-1" />
161113

162-
{/* Volume — always accessible */}
163-
<VolumeControl />
114+
<span
115+
className="rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground/60"
116+
title="Spotify embeds do not expose volume control. Adjust volume in Spotify or with your system/browser controls."
117+
>
118+
Volume in Spotify/system
119+
</span>
164120

165121
{/* Playlist picker toggle (only when not minimized) */}
166122
{!minimized && (

apps/web/src/spotifyPlayerStore.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ interface PersistedSpotifyState {
4545
minimized: boolean;
4646
selectedPlaylistUri: string | null;
4747
customUri: string | null;
48-
volume: number;
4948
}
5049

5150
interface SpotifyPlayerStore extends PersistedSpotifyState {
@@ -54,7 +53,6 @@ interface SpotifyPlayerStore extends PersistedSpotifyState {
5453
setMinimized: (minimized: boolean) => void;
5554
selectPlaylist: (uri: string) => void;
5655
setCustomUri: (uri: string | null) => void;
57-
setVolume: (volume: number) => void;
5856
}
5957

6058
const STORAGE_KEY = "okcode:spotify-player:v1";
@@ -65,7 +63,6 @@ function readPersistedState(): PersistedSpotifyState {
6563
minimized: false,
6664
selectedPlaylistUri: null,
6765
customUri: null,
68-
volume: 80,
6966
};
7067

7168
if (typeof window === "undefined") return defaults;
@@ -81,10 +78,6 @@ function readPersistedState(): PersistedSpotifyState {
8178
selectedPlaylistUri:
8279
typeof parsed.selectedPlaylistUri === "string" ? parsed.selectedPlaylistUri : null,
8380
customUri: typeof parsed.customUri === "string" ? parsed.customUri : null,
84-
volume:
85-
typeof parsed.volume === "number" && Number.isFinite(parsed.volume)
86-
? Math.max(0, Math.min(100, parsed.volume))
87-
: 80,
8881
};
8982
} catch {
9083
return defaults;
@@ -130,12 +123,6 @@ export const useSpotifyPlayerStore = create<SpotifyPlayerStore>((set, get) => ({
130123
set({ customUri: uri });
131124
persistState({ ...get(), customUri: uri });
132125
},
133-
134-
setVolume: (volume) => {
135-
const clamped = Math.max(0, Math.min(100, volume));
136-
set({ volume: clamped });
137-
persistState({ ...get(), volume: clamped });
138-
},
139126
}));
140127

141128
/**

0 commit comments

Comments
 (0)