Skip to content

Commit

Permalink
[APT-10128] Update Reducer logic to copy seek target to playback info…
Browse files Browse the repository at this point in the history
… progress
  • Loading branch information
griffinfscribd committed Jun 4, 2024
1 parent 7f123c9 commit 1e6ec21
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion Armadillo/src/main/java/com/scribd/armadillo/Reducer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,25 @@ internal object Reducer {
isSeeking = action.isSeeking,
seekTarget = action.seekPositionTarget)
} else MediaControlState()

val progress = if (action.seekPositionTarget != null) {
playbackInfo.progress.copy(positionInDuration = action.seekPositionTarget)
} else {
playbackInfo.progress
}
oldState.copy(playbackInfo = playbackInfo.copy(
progress = progress,
controlState = controlState))
.apply { debugState = newDebug }
}
is FastForwardAction -> {
val playbackInfo = oldState.playbackInfo ?: throw ActionBeforeSetup(action)
val progress = if (action.seekPositionTarget != null) {
playbackInfo.progress.copy(positionInDuration = action.seekPositionTarget)
} else {
playbackInfo.progress
}
oldState.copy(playbackInfo = playbackInfo.copy(
progress = progress,
controlState = MediaControlState(
isSeeking = true,
isFastForwarding = true,
Expand All @@ -191,7 +202,13 @@ internal object Reducer {
}
is RewindAction -> {
val playbackInfo = oldState.playbackInfo ?: throw ActionBeforeSetup(action)
val progress = if (action.seekPositionTarget != null) {
playbackInfo.progress.copy(positionInDuration = action.seekPositionTarget)
} else {
playbackInfo.progress
}
oldState.copy(playbackInfo = playbackInfo.copy(
progress = progress,
controlState = MediaControlState(
isSeeking = true,
isRewinding = true,
Expand All @@ -200,7 +217,13 @@ internal object Reducer {
}
is SkipNextAction -> {
val playbackInfo = oldState.playbackInfo ?: throw ActionBeforeSetup(action)
val progress = if (action.seekPositionTarget != null) {
playbackInfo.progress.copy(positionInDuration = action.seekPositionTarget)
} else {
playbackInfo.progress
}
oldState.copy(playbackInfo = playbackInfo.copy(
progress = progress,
controlState = MediaControlState(
isSeeking = true,
isNextChapter = true,
Expand All @@ -209,7 +232,13 @@ internal object Reducer {
}
is SkipPrevAction -> {
val playbackInfo = oldState.playbackInfo ?: throw ActionBeforeSetup(action)
val progress = if (action.seekPositionTarget != null) {
playbackInfo.progress.copy(positionInDuration = action.seekPositionTarget)
} else {
playbackInfo.progress
}
oldState.copy(playbackInfo = playbackInfo.copy(
progress = progress,
controlState = MediaControlState(
isSeeking = true,
isPrevChapter = true,
Expand Down

0 comments on commit 1e6ec21

Please sign in to comment.