diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/NewIdentityScreen.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/NewIdentityScreen.kt index 80a3393..b54064e 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/NewIdentityScreen.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/NewIdentityScreen.kt @@ -1,8 +1,6 @@ package su.reya.coop.screens import androidx.compose.runtime.Composable -import androidx.compose.runtime.rememberCoroutineScope -import kotlinx.coroutines.launch import su.reya.coop.LocalAuthViewModel import su.reya.coop.LocalNavigator import su.reya.coop.Screen @@ -12,17 +10,14 @@ import su.reya.coop.shared.ProfileEditor fun NewIdentityScreen() { val authViewModel = LocalAuthViewModel.current val navigator = LocalNavigator.current - val scope = rememberCoroutineScope() ProfileEditor( title = "Create a new identity", buttonLabel = "Continue", onBack = { navigator.goBack() }, onConfirm = { name, bio, bytes, type -> - scope.launch { - authViewModel.createIdentity(name, bio, bytes, type) - navigator.navigate(Screen.Home) - } + authViewModel.createIdentity(name, bio, bytes, type) + navigator.navigate(Screen.Home) } ) } diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/UpdateProfileScreen.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/UpdateProfileScreen.kt index efa531a..c044f0e 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/UpdateProfileScreen.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/UpdateProfileScreen.kt @@ -2,9 +2,7 @@ package su.reya.coop.screens import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.rememberCoroutineScope import androidx.lifecycle.compose.collectAsStateWithLifecycle -import kotlinx.coroutines.launch import su.reya.coop.LocalNavigator import su.reya.coop.LocalNostrViewModel import su.reya.coop.shared.ProfileEditor @@ -13,7 +11,6 @@ import su.reya.coop.shared.ProfileEditor fun UpdateProfileScreen() { val nostrViewModel = LocalNostrViewModel.current val navigator = LocalNavigator.current - val scope = rememberCoroutineScope() val currentUser by nostrViewModel.currentUserProfile.collectAsStateWithLifecycle() val profile = currentUser?.metadata?.asRecord() @@ -26,10 +23,8 @@ fun UpdateProfileScreen() { initialPicture = profile?.picture, onBack = { navigator.goBack() }, onConfirm = { name, bio, bytes, type -> - scope.launch { - nostrViewModel.updateProfile(name, bio, bytes, type) - navigator.goBack() - } + nostrViewModel.updateProfile(name, bio, bytes, type) + navigator.goBack() } ) } diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/shared/ProfileEditor.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/shared/ProfileEditor.kt index e975f85..b3827fb 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/shared/ProfileEditor.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/shared/ProfileEditor.kt @@ -69,7 +69,7 @@ fun ProfileEditor( initialBio: String = "", initialPicture: Any? = null, // Accepts Uri (picked) or String (current URL) onBack: () -> Unit, - onConfirm: (name: String, bio: String, pictureBytes: ByteArray?, contentType: String?) -> Unit + onConfirm: suspend (name: String, bio: String, pictureBytes: ByteArray?, contentType: String?) -> Unit ) { val context = LocalContext.current val snackbarHostState = LocalSnackbarHostState.current