mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-07-26 14:32:28 +00:00
fix(tracking): close early scrobble sessions
This commit is contained in:
parent
d8ffd18c4d
commit
44fc3fa62f
2 changed files with 57 additions and 1 deletions
|
|
@ -187,7 +187,10 @@ private fun PlayerScreenRuntime.emitTrackingScrobbleTerminal(
|
|||
|
||||
internal fun PlayerScreenRuntime.emitStopScrobbleForCurrentProgress() {
|
||||
val progressPercent = currentPlaybackProgressPercent()
|
||||
if (progressPercent >= 1f && progressPercent < 80f) {
|
||||
if (!shouldSendStopScrobble(hasRequestedScrobbleStartForCurrentItem, progressPercent)) {
|
||||
return
|
||||
}
|
||||
if (progressPercent < 80f) {
|
||||
emitTrackingScrobbleStop(progressPercent)
|
||||
return
|
||||
}
|
||||
|
|
@ -198,6 +201,11 @@ internal fun PlayerScreenRuntime.emitStopScrobbleForCurrentProgress() {
|
|||
}
|
||||
}
|
||||
|
||||
internal fun shouldSendStopScrobble(
|
||||
hasActiveScrobble: Boolean,
|
||||
progressPercent: Float,
|
||||
): Boolean = hasActiveScrobble || progressPercent >= 80f
|
||||
|
||||
internal fun shouldUpdateTrackingScrobbleAfterSeek(
|
||||
hasActiveScrobble: Boolean,
|
||||
progressPercent: Float,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,54 @@ class PlayerScreenRuntimeStateTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun stopScrobble_closesActiveSessionBelowOnePercent() {
|
||||
assertTrue(
|
||||
shouldSendStopScrobble(
|
||||
hasActiveScrobble = true,
|
||||
progressPercent = 0f,
|
||||
),
|
||||
)
|
||||
assertTrue(
|
||||
shouldSendStopScrobble(
|
||||
hasActiveScrobble = true,
|
||||
progressPercent = 0.5f,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun stopScrobble_skipsEarlyProgressWithoutActiveSession() {
|
||||
assertFalse(
|
||||
shouldSendStopScrobble(
|
||||
hasActiveScrobble = false,
|
||||
progressPercent = 0.5f,
|
||||
),
|
||||
)
|
||||
assertFalse(
|
||||
shouldSendStopScrobble(
|
||||
hasActiveScrobble = false,
|
||||
progressPercent = 79.99f,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun stopScrobble_allowsCompletionWithoutActiveSession() {
|
||||
assertTrue(
|
||||
shouldSendStopScrobble(
|
||||
hasActiveScrobble = false,
|
||||
progressPercent = 80f,
|
||||
),
|
||||
)
|
||||
assertTrue(
|
||||
shouldSendStopScrobble(
|
||||
hasActiveScrobble = false,
|
||||
progressPercent = 100f,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun testPlayerScreenArgs() = PlayerScreenArgs(
|
||||
profileId = 1,
|
||||
title = "Title",
|
||||
|
|
|
|||
Loading…
Reference in a new issue