Skip to content

Commit

Permalink
Fix programme cell won't call the latest onPressed callback if you ch…
Browse files Browse the repository at this point in the history
…eckout the tabs.
  • Loading branch information
oxyroid committed Jul 20, 2024
1 parent ebd7f26 commit ab8d00e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -135,7 +134,6 @@ internal fun PlayerPanel(
animProgramme = it
}
)
val currentProgramme = animProgramme
LaunchedEffect(isPanelExpanded) {
if (!isPanelExpanded) {
programme = null
Expand All @@ -152,6 +150,7 @@ internal fun PlayerPanel(
onClick = { programme = null }
)
) {
val currentProgramme = animProgramme
if (currentProgramme != null) {
Surface(
color = MaterialTheme.colorScheme.surfaceContainer,
Expand Down Expand Up @@ -243,10 +242,6 @@ internal fun PlayerPanel(
}
}
}

DisposableEffect(Unit) {
onDispose { animProgramme = null }
}
}
BackStackHandler(
entry = BackStackEntry(Icons.Rounded.Close),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ private fun ProgrammeCell(
modifier: Modifier = Modifier,
onPressed: () -> Unit
) {
val currentOnPressed by rememberUpdatedState(onPressed)
val spacing = LocalSpacing.current
val preferences = hiltPreferences()
val leanback = leanback()
Expand Down Expand Up @@ -367,7 +368,7 @@ private fun ProgrammeCell(
}
} catch (_: PointerEventTimeoutCancellationException) {
down.consume()
onPressed()
currentOnPressed()
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
isPressed = true
do {
Expand Down

0 comments on commit ab8d00e

Please sign in to comment.