Uses default thread to wait for a 250 milliseconds before navigating away from the video upload page.

This commit is contained in:
Vitor Pamplona
2023-06-08 16:31:04 -04:00
parent 9589f68028
commit b641684377
@@ -88,8 +88,10 @@ import com.vitorpamplona.amethyst.ui.screen.NostrVideoFeedViewModel
import com.vitorpamplona.amethyst.ui.screen.ScrollStateKeys import com.vitorpamplona.amethyst.ui.screen.ScrollStateKeys
import com.vitorpamplona.amethyst.ui.screen.rememberForeverPagerState import com.vitorpamplona.amethyst.ui.screen.rememberForeverPagerState
import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@Composable @Composable
fun VideoScreen( fun VideoScreen(
@@ -415,13 +417,15 @@ fun NewImageButton(accountViewModel: AccountViewModel, nav: (String) -> Unit) {
val postViewModel: NewMediaModel = viewModel() val postViewModel: NewMediaModel = viewModel()
postViewModel.onceUploaded { postViewModel.onceUploaded {
scope.launch { scope.launch(Dispatchers.Default) {
// awaits an refresh on the list // awaits an refresh on the list
delay(250) delay(250)
withContext(Dispatchers.Main) {
val route = Route.Video.route.replace("{scrollToTop}", "true") val route = Route.Video.route.replace("{scrollToTop}", "true")
nav(route) nav(route)
} }
} }
}
if (wantsToPost) { if (wantsToPost) {
val cameraPermissionState = val cameraPermissionState =