From d7160af908cb6205a7a74bc500e4fdbbae94b5e9 Mon Sep 17 00:00:00 2001 From: benya Date: Sun, 8 Mar 2026 12:42:07 +0300 Subject: [PATCH] ui: move audio volume control to top player bar --- web/src/components/MessageList.tsx | 18 ------------------ web/src/pages/ChatsPage.tsx | 13 ++++++++++++- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/web/src/components/MessageList.tsx b/web/src/components/MessageList.tsx index b472160..4af5935 100644 --- a/web/src/components/MessageList.tsx +++ b/web/src/components/MessageList.tsx @@ -957,17 +957,14 @@ function AudioInlinePlayer({ src, title }: { src: string; title: string }) { const isPlayingGlobal = useAudioPlayerStore((s) => s.isPlaying); const durationGlobal = useAudioPlayerStore((s) => s.duration); const positionGlobal = useAudioPlayerStore((s) => s.position); - const volumeGlobal = useAudioPlayerStore((s) => s.volume); const playTrack = useAudioPlayerStore((s) => s.playTrack); const togglePlayGlobal = useAudioPlayerStore((s) => s.togglePlay); const seekToGlobal = useAudioPlayerStore((s) => s.seekTo); - const setVolumeGlobal = useAudioPlayerStore((s) => s.setVolume); const isActiveTrack = track?.src === src; const isPlaying = isActiveTrack && isPlayingGlobal; const duration = isActiveTrack ? durationGlobal : 0; const position = isActiveTrack ? positionGlobal : 0; - const volume = volumeGlobal; async function togglePlay() { if (isActiveTrack) { @@ -984,10 +981,6 @@ function AudioInlinePlayer({ src, title }: { src: string; title: string }) { seekToGlobal(nextValue); } - function onVolume(nextValue: number) { - setVolumeGlobal(nextValue); - } - return (
@@ -1012,17 +1005,6 @@ function AudioInlinePlayer({ src, title }: { src: string; title: string }) { {formatAudioTime(position)} / {formatAudioTime(duration)} - - πŸ”Š - onVolume(Number(event.target.value))} - step={0.05} - type="range" - value={volume} - />
); diff --git a/web/src/pages/ChatsPage.tsx b/web/src/pages/ChatsPage.tsx index c81ba37..e900fa4 100644 --- a/web/src/pages/ChatsPage.tsx +++ b/web/src/pages/ChatsPage.tsx @@ -31,6 +31,7 @@ export function ChatsPage() { const activeTrack = useAudioPlayerStore((s) => s.track); const isAudioPlaying = useAudioPlayerStore((s) => s.isPlaying); const audioVolume = useAudioPlayerStore((s) => s.volume); + const setAudioVolume = useAudioPlayerStore((s) => s.setVolume); const toggleAudioPlay = useAudioPlayerStore((s) => s.togglePlay); const stopAudio = useAudioPlayerStore((s) => s.stop); const audioEl = useAudioPlayerStore((s) => s.audioEl); @@ -243,7 +244,17 @@ export function ChatsPage() { - πŸ”Š {Math.round(audioVolume * 100)}% + πŸ”Š + setAudioVolume(Number(event.target.value))} + step={0.05} + type="range" + value={audioVolume} + /> + {Math.round(audioVolume * 100)}%