bugfix: remove duplicate scrobbling when there is only one item in the queue (#1222)

This commit is contained in:
Kendall Garner 2025-10-25 20:25:07 +00:00 committed by GitHub
parent ff0ca09644
commit 58ccd0cfd0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,
});