From 2e29914df0c63ef912f6caeede68a3dab5bfa1d8 Mon Sep 17 00:00:00 2001 From: Victor Alves Date: Thu, 31 Oct 2024 08:41:37 -0300 Subject: [PATCH 1/3] fix: include pointer and mouse up events for progress slider --- src/app/components/player/progress.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app/components/player/progress.tsx b/src/app/components/player/progress.tsx index ac09ec9..38b63bf 100644 --- a/src/app/components/player/progress.tsx +++ b/src/app/components/player/progress.tsx @@ -55,6 +55,12 @@ export function PlayerProgress({ audioRef, song }: PlayerProgressProps) { [audioRef, setProgress], ) + function handleSeekedFallback() { + if (localProgress !== progress) { + setProgress(localProgress) + } + } + const songDuration = useMemo( () => convertSecondsToTime(currentDuration ?? 0), [currentDuration], @@ -102,6 +108,11 @@ export function PlayerProgress({ audioRef, song }: PlayerProgressProps) { className="cursor-pointer w-[32rem]" onValueChange={([value]) => handleSeeking(value)} onValueCommit={([value]) => handleSeeked(value)} + // Sometimes onValueCommit doesn't work properly + // so we also have to set the value on pointer/mouse up events + // see https://github.com/radix-ui/primitives/issues/1760 + onPointerUp={handleSeekedFallback} + onMouseUp={handleSeekedFallback} data-testid="player-progress-slider" /> ) : ( From 80562ebf85c80548beadace3ad30f533c7224e3e Mon Sep 17 00:00:00 2001 From: Victor Alves Date: Thu, 31 Oct 2024 08:43:08 -0300 Subject: [PATCH 2/3] chore: bump to v0.3.2 --- package.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a9bc899..d298ebd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "aonsoku", "private": true, - "version": "0.3.1", + "version": "0.3.2", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 3b22816..4e4ef55 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -64,7 +64,7 @@ checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" [[package]] name = "aonsoku" -version = "0.3.1" +version = "0.3.2" dependencies = [ "futures-util", "regex", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 39ce4d0..133d5d7 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aonsoku" -version = "0.3.1" +version = "0.3.2" description = "A modern desktop client for Navidrome/Subsonic servers." authors = ["Victor Alves"] edition = "2021" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index f2e4d23..9e3a179 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -7,7 +7,7 @@ }, "package": { "productName": "Aonsoku", - "version": "0.3.1" + "version": "0.3.2" }, "tauri": { "allowlist": { From b608358ee499b9ffaac94ac46a43068939424fc7 Mon Sep 17 00:00:00 2001 From: Victor Alves Date: Thu, 31 Oct 2024 09:23:29 -0300 Subject: [PATCH 3/3] fix: update audio current time on both events --- src/app/components/player/progress.tsx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app/components/player/progress.tsx b/src/app/components/player/progress.tsx index 38b63bf..19dde9f 100644 --- a/src/app/components/player/progress.tsx +++ b/src/app/components/player/progress.tsx @@ -35,6 +35,16 @@ export function PlayerProgress({ audioRef, song }: PlayerProgressProps) { const { setProgress } = usePlayerActions() const isScrobbleSentRef = useRef(false) + const updateAudioCurrentTime = useCallback( + (value: number) => { + isSeeking = false + if (audioRef.current) { + audioRef.current.currentTime = value + } + }, + [audioRef], + ) + const handleSeeking = useCallback( (amount: number) => { isSeeking = true @@ -45,21 +55,19 @@ export function PlayerProgress({ audioRef, song }: PlayerProgressProps) { const handleSeeked = useCallback( (amount: number) => { - isSeeking = false - if (audioRef.current) { - audioRef.current.currentTime = amount - } + updateAudioCurrentTime(amount) setProgress(amount) setLocalProgress(amount) }, - [audioRef, setProgress], + [setProgress, updateAudioCurrentTime], ) - function handleSeekedFallback() { + const handleSeekedFallback = useCallback(() => { if (localProgress !== progress) { + updateAudioCurrentTime(localProgress) setProgress(localProgress) } - } + }, [localProgress, progress, setProgress, updateAudioCurrentTime]) const songDuration = useMemo( () => convertSecondsToTime(currentDuration ?? 0),