From 58ccd0cfd01bf420584d70c237fd273390b12c1d Mon Sep 17 00:00:00 2001 From: Kendall Garner <17521368+kgarner7@users.noreply.github.com> Date: Sat, 25 Oct 2025 20:25:07 +0000 Subject: [PATCH] bugfix: remove duplicate scrobbling when there is only one item in the queue (#1222) --- src/renderer/features/player/hooks/use-scrobble.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/renderer/features/player/hooks/use-scrobble.ts b/src/renderer/features/player/hooks/use-scrobble.ts index 04dbb86d..d7f21856 100644 --- a/src/renderer/features/player/hooks/use-scrobble.ts +++ b/src/renderer/features/player/hooks/use-scrobble.ts @@ -268,6 +268,7 @@ export const useScrobble = () => { } } else { const isLastTrackInQueue = usePlayerStore.getState().actions.checkIsLastTrack(); + const isFisrtTrackInQueue = usePlayerStore.getState().actions.checkIsFirstTrack(); const previousTimeSec = previous[1]; // If not already scrobbled, send a 'submission' scrobble if conditions are met @@ -275,8 +276,12 @@ export const useScrobble = () => { scrobbleAtDurationMs: (scrobbleSettings?.scrobbleAtDuration ?? 0) * 1000, scrobbleAtPercentage: scrobbleSettings?.scrobbleAtPercentage, // If scrobbling the last song in the queue, use the previous time instead of the current time since otherwise time value will be 0 + // Note that if the queue has one item (both first and last), use the elapsed time, as this will otherwise result + // in duplicate scrobbles in tandem with handleScrobbleFromSongChange songCompletedDurationMs: - (isLastTrackInQueue ? previousTimeSec : currentTimeSec) * 1000, + (isLastTrackInQueue && !isFisrtTrackInQueue + ? previousTimeSec + : currentTimeSec) * 1000, songDurationMs: currentSong.duration, });