Skip to content

Commit

Permalink
Fix the logic for showing the button
Browse files Browse the repository at this point in the history
This is essentially the same logic, only broken down to cover a missed case and make it easier to follow
  • Loading branch information
AbandonedCart committed Oct 11, 2024
1 parent bdcfbc5 commit 0193d65
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,21 @@ class SegmentSkipFragment : Fragment() {
val currentSegment = getCurrentSegment(currentPosition) ?: lastSegment ?: return
lastSegment = currentSegment

val shouldPerformSkip = currentPosition >= currentSegment.showAt.millis && currentPosition < currentSegment.hideAt.millis

if (!button.isVisible && shouldPerformSkip && preferences[UserPreferences.skipMode] == SegmentMode.SHOW_SKIP_BUTTON
&& buttonConfig?.skipButtonVisible == true) {
button.isVisible = true
updateButtonText(currentSegment)
button.requestFocus()
} else if (button.isVisible && (!shouldPerformSkip || preferences[UserPreferences.skipMode] != SegmentMode.SHOW_SKIP_BUTTON)) {
val isSkipSegment = currentPosition >= currentSegment.showAt.millis && currentPosition < currentSegment.hideAt.millis

if (preferences[UserPreferences.skipMode] == SegmentMode.SHOW_SKIP_BUTTON) {
if (!button.isVisible && isSkipSegment && buttonConfig?.skipButtonVisible == true) {
button.isVisible = true
updateButtonText(currentSegment)
button.requestFocus()
} else if (button.isVisible && !isSkipSegment) {
button.isVisible = false
}
} else {
button.isVisible = false
}

if (shouldPerformSkip && preferences[UserPreferences.skipMode] == SegmentMode.AUTO_SKIP) {
if (isSkipSegment && preferences[UserPreferences.skipMode] == SegmentMode.AUTO_SKIP) {
doSkip()
}
}
Expand Down

0 comments on commit 0193d65

Please sign in to comment.