Skip to content

Commit

Permalink
Merge pull request #67 from victoralvesf/development
Browse files Browse the repository at this point in the history
v0.3.2
  • Loading branch information
victoralvesf authored Oct 31, 2024
2 parents 0408894 + f8d6a65 commit 4932a81
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "aonsoku",
"private": true,
"version": "0.3.1",
"version": "0.3.2",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "Aonsoku",
"version": "0.3.1"
"version": "0.3.2"
},
"tauri": {
"allowlist": {
Expand Down
29 changes: 24 additions & 5 deletions src/app/components/player/progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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],
Expand Down Expand Up @@ -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"
/>
) : (
Expand Down

0 comments on commit 4932a81

Please sign in to comment.