Skip to content

Commit

Permalink
Select Artists page playback fixes (#7343)
Browse files Browse the repository at this point in the history
  • Loading branch information
DejayJD authored Jan 30, 2024
1 parent 583e266 commit cd81ec8
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,26 @@ export const SelectArtistsPreviewContextProvider = (props: {
return
}
if (!track) return

const { track_id, preview_cid, duration } = track
// Sometimes we rerender before the next track starts playing, so we need to double check the track matches the artist
if (track.user.user_id !== nowPlayingArtistId) return
const isPreview = !!preview_cid
const startTime = isPreview
? undefined
: Math.min(30, Math.max(0, duration - 30))

dispatch(playerActions.play({ trackId: track_id, startTime, isPreview }))
dispatch(
playerActions.play({
trackId: track_id,
startTime,
isPreview,
onEnd: () => {
stopPreview()
}
})
)

setIsPlaying(true)
}, [nowPlayingArtistId, stopPreview, track, dispatch])
Expand Down

0 comments on commit cd81ec8

Please sign in to comment.