From 5f473043d550042eb9c76467642d4e3589840c73 Mon Sep 17 00:00:00 2001 From: urFate Date: Tue, 23 Apr 2024 09:49:05 +0300 Subject: [PATCH] perf(PlayerControls): move instant seek zones hiding task to a LaunchedEffect block --- .../ui/activity/player/PlayerControls.kt | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/live/shirabox/shirabox/ui/activity/player/PlayerControls.kt b/app/src/main/java/live/shirabox/shirabox/ui/activity/player/PlayerControls.kt index 1afd4e2..42600cc 100644 --- a/app/src/main/java/live/shirabox/shirabox/ui/activity/player/PlayerControls.kt +++ b/app/src/main/java/live/shirabox/shirabox/ui/activity/player/PlayerControls.kt @@ -430,15 +430,16 @@ fun InstantSeekZones( ) { val deviceWidth = LocalConfiguration.current.screenWidthDp.dp - var showRewindUi by remember { - mutableStateOf(false) + var showRewindUi by remember { mutableStateOf(false) } + var showForwardUi by remember { mutableStateOf(false) } + + LaunchedEffect(showRewindUi) { + if(showRewindUi) delay(1000L).let { showRewindUi = false } } - var showForwardUi by remember { - mutableStateOf(false) + LaunchedEffect(showForwardUi) { + if(showForwardUi) delay(1000L).let { showForwardUi = false } } - val coroutineScope = rememberCoroutineScope() - // Rewind seek zone SeekZoneBox( modifier = Modifier @@ -449,9 +450,6 @@ fun InstantSeekZones( onDoubleClick = { onFastRewind(it) showRewindUi = true - coroutineScope.launch { - delay(1000L).let { showRewindUi = false } - } }, onClick = onClick ) @@ -465,9 +463,6 @@ fun InstantSeekZones( onDoubleClick = { onFastForward(it) showForwardUi = true - coroutineScope.launch { - delay(1000L).let { showForwardUi = false } - } }, onClick = onClick )