mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
bugfix: remove duplicate scrobbling when there is only one item in the queue (#1222)
This commit is contained in:
@@ -268,6 +268,7 @@ export const useScrobble = () => {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const isLastTrackInQueue = usePlayerStore.getState().actions.checkIsLastTrack();
|
const isLastTrackInQueue = usePlayerStore.getState().actions.checkIsLastTrack();
|
||||||
|
const isFisrtTrackInQueue = usePlayerStore.getState().actions.checkIsFirstTrack();
|
||||||
const previousTimeSec = previous[1];
|
const previousTimeSec = previous[1];
|
||||||
|
|
||||||
// If not already scrobbled, send a 'submission' scrobble if conditions are met
|
// If not already scrobbled, send a 'submission' scrobble if conditions are met
|
||||||
@@ -275,8 +276,12 @@ export const useScrobble = () => {
|
|||||||
scrobbleAtDurationMs: (scrobbleSettings?.scrobbleAtDuration ?? 0) * 1000,
|
scrobbleAtDurationMs: (scrobbleSettings?.scrobbleAtDuration ?? 0) * 1000,
|
||||||
scrobbleAtPercentage: scrobbleSettings?.scrobbleAtPercentage,
|
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
|
// 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:
|
songCompletedDurationMs:
|
||||||
(isLastTrackInQueue ? previousTimeSec : currentTimeSec) * 1000,
|
(isLastTrackInQueue && !isFisrtTrackInQueue
|
||||||
|
? previousTimeSec
|
||||||
|
: currentTimeSec) * 1000,
|
||||||
songDurationMs: currentSong.duration,
|
songDurationMs: currentSong.duration,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user