From 41e47fa71db04bce532091772ae91407ad6199b4 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 17 Feb 2025 11:17:38 -0500 Subject: [PATCH] Fixes running new events on the main thread. --- .../amethyst/ui/screen/loggedIn/NewPostScreen.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NewPostScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NewPostScreen.kt index bf4295c85..7b3d94684 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NewPostScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NewPostScreen.kt @@ -193,6 +193,7 @@ import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import java.lang.Math.round @OptIn(ExperimentalMaterial3Api::class, FlowPreview::class) @@ -325,8 +326,10 @@ fun NewPostScreen( CloseButton( onPress = { scope.launch { - postViewModel.sendDraftSync(relayList = relayList) - postViewModel.cancel() + withContext(Dispatchers.IO) { + postViewModel.sendDraftSync(relayList = relayList) + postViewModel.cancel() + } delay(100) nav.popBack() }