Reduces interruptions to the main thread

This commit is contained in:
Vitor Pamplona 2024-07-16 08:41:48 -04:00
parent f1e3f6a592
commit 8de4d461d4

View File

@ -104,6 +104,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlin.time.Duration.Companion.seconds
@Composable @Composable
fun ZoomableContentView( fun ZoomableContentView(
@ -180,16 +181,12 @@ fun TwoSecondController(
content: BaseMediaContent, content: BaseMediaContent,
inner: @Composable (controllerVisible: MutableState<Boolean>) -> Unit, inner: @Composable (controllerVisible: MutableState<Boolean>) -> Unit,
) { ) {
val controllerVisible = remember { mutableStateOf(true) } val controllerVisible = remember(content) { mutableStateOf(true) }
LaunchedEffect(content) { LaunchedEffect(content) {
launch(Dispatchers.Default) { delay(2.seconds)
delay(2000)
withContext(Dispatchers.Main) {
controllerVisible.value = false controllerVisible.value = false
} }
}
}
inner(controllerVisible) inner(controllerVisible)
} }