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": { diff --git a/src/app/components/player/progress.tsx b/src/app/components/player/progress.tsx index ac09ec9..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,16 +55,20 @@ 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], ) + const handleSeekedFallback = useCallback(() => { + if (localProgress !== progress) { + updateAudioCurrentTime(localProgress) + setProgress(localProgress) + } + }, [localProgress, progress, setProgress, updateAudioCurrentTime]) + const songDuration = useMemo( () => convertSecondsToTime(currentDuration ?? 0), [currentDuration], @@ -102,6 +116,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" /> ) : (