web music: closing the dock clears the saved now-playing (so it stays closed)

The dock's X only reset local player state; the server's now-playing snapshot
survived, so a reload restored the dock. Closing now also DELETEs /music/now-playing
before clearing the queue.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-28 14:56:40 +00:00
co-authored by Claude Opus 4.8
parent 2540c9f5d3
commit cc141ae91a
@@ -30,7 +30,7 @@ const fmt = (s: number): string =>
Number.isFinite(s) && s >= 0 ? `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, '0')}` : '0:00';
export const MusicPlayerHost = () => {
const { token, get, put } = useClient();
const { token, get, put, delete: del } = useClient();
const navigate = useNavigate();
const [, setCwd] = usePanelChannel<string | null>(MUSIC_CWD_CHANNEL, null);
const { current, index, queue, playing, toggle, next, prev, setPlaying, syncIndex, close, loadQueue } =
@@ -233,6 +233,13 @@ export const MusicPlayerHost = () => {
const subtitle = current?.artist ?? current?.albumRel.split('/').slice(-2, -1)[0] ?? '';
const pct = duration ? (position / duration) * 100 : 0;
// Closing the dock also clears the saved "currently playing" snapshot, so it doesn't get restored on
// the next load. (Merely close()-ing the local queue would leave the server snapshot to bring it back.)
const handleClose = () => {
del('/music/now-playing').catch(() => {});
close();
};
// Clicking the track info jumps the /music library to the playing album (and navigates there).
const openCurrentAlbum = () => {
if (!current) return;
@@ -347,7 +354,7 @@ export const MusicPlayerHost = () => {
<button
type="button"
onClick={close}
onClick={handleClose}
className="shrink-0 cursor-pointer p-1.5 text-muted-foreground hover:text-foreground"
>
<X size={16} />