fix: improve trakt scrobble handling

This commit is contained in:
tapframe 2026-05-02 14:27:04 +05:30
parent 4f62be91b8
commit 1523177ffa

View file

@ -223,7 +223,6 @@ fun PlayerScreen(
activeEpisodeNumber,
) { mutableStateOf(false) }
var hasSentCompletionScrobbleForCurrentItem by remember(
activeSourceUrl,
activeVideoId,
activeSeasonNumber,
activeEpisodeNumber,
@ -379,7 +378,6 @@ fun PlayerScreen(
val progressPercent = currentPlaybackProgressPercent()
if (progressPercent >= 1f && progressPercent < 80f) {
emitTraktScrobbleStop(progressPercent)
hasSentCompletionScrobbleForCurrentItem = false
return
}
@ -1195,15 +1193,20 @@ fun PlayerScreen(
pausedOverlayVisible = true
}
LaunchedEffect(playbackSnapshot.positionMs, playbackSnapshot.isPlaying, playbackSnapshot.isEnded, playbackSnapshot.durationMs) {
LaunchedEffect(
playbackSnapshot.positionMs,
playbackSnapshot.isPlaying,
playbackSnapshot.isLoading,
playbackSnapshot.isEnded,
playbackSnapshot.durationMs,
) {
if (playbackSnapshot.isEnded) {
hasSentCompletionScrobbleForCurrentItem = false
flushWatchProgress()
previousIsPlaying = false
return@LaunchedEffect
}
if (previousIsPlaying && !playbackSnapshot.isPlaying) {
if (previousIsPlaying && !playbackSnapshot.isPlaying && !playbackSnapshot.isLoading) {
flushWatchProgress()
}
@ -1211,7 +1214,9 @@ fun PlayerScreen(
emitTraktScrobbleStart()
}
previousIsPlaying = playbackSnapshot.isPlaying
if (!playbackSnapshot.isLoading) {
previousIsPlaying = playbackSnapshot.isPlaying
}
if (!playbackSnapshot.isPlaying) {
return@LaunchedEffect