diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataScreen.kt index 6d8b8c1f5..0fa2fd845 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataScreen.kt @@ -61,7 +61,7 @@ fun NewUserMetadataScreen( postViewModel.init(accountViewModel) val context = LocalContext.current - LaunchedEffect(accountViewModel) { + LaunchedEffect(postViewModel, accountViewModel) { postViewModel.load() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt index d05efddce..d5874e824 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt @@ -104,7 +104,7 @@ fun ReplyCommentPostScreen( val context = LocalContext.current - LaunchedEffect(Unit) { + LaunchedEffect(postViewModel, accountViewModel) { reply?.let { postViewModel.reply(it) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/ChatroomView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/ChatroomView.kt index ec40203d9..214684a90 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/ChatroomView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/ChatroomView.kt @@ -70,7 +70,7 @@ fun ChatroomView( newPostModel.load(room) if (replyToNote != null) { - LaunchedEffect(key1 = replyToNote) { + LaunchedEffect(key1 = replyToNote, newPostModel, accountViewModel) { accountViewModel.checkGetOrCreateNote(replyToNote) { if (it != null) { newPostModel.reply(it) @@ -79,7 +79,7 @@ fun ChatroomView( } } if (editFromDraft != null) { - LaunchedEffect(key1 = replyToNote) { + LaunchedEffect(replyToNote, newPostModel, accountViewModel) { accountViewModel.checkGetOrCreateNote(editFromDraft) { if (it != null) { newPostModel.editFromDraft(it) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/NewGroupDMScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/NewGroupDMScreen.kt index 4d785f670..94f18b6a6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/NewGroupDMScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/NewGroupDMScreen.kt @@ -151,12 +151,12 @@ fun NewGroupDMScreen( val context = LocalContext.current - LaunchedEffect(Unit) { - withContext(Dispatchers.IO) { - message?.ifBlank { null }?.let { - postViewModel.updateMessage(TextFieldValue(it)) - } - attachment?.let { + LaunchedEffect(postViewModel, accountViewModel) { + message?.ifBlank { null }?.let { + postViewModel.updateMessage(TextFieldValue(it)) + } + attachment?.let { + withContext(Dispatchers.IO) { val mediaType = context.contentResolver.getType(it) postViewModel.pickedMedia(persistentListOf(SelectedMedia(it, mediaType))) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductScreen.kt index 25f64e65f..9d0ec5516 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductScreen.kt @@ -101,7 +101,7 @@ fun NewProductScreen( val context = LocalContext.current - LaunchedEffect(Unit) { + LaunchedEffect(postViewModel, accountViewModel) { postViewModel.reloadRelaySet() draft?.let { postViewModel.editFromDraft(it) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/GeoHashPostScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/GeoHashPostScreen.kt index 6baf3fdf3..03597a7b6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/GeoHashPostScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/GeoHashPostScreen.kt @@ -53,7 +53,7 @@ fun GeoHashPostScreen( val context = LocalContext.current - LaunchedEffect(Unit) { + LaunchedEffect(postViewModel, accountViewModel) { geohash?.let { postViewModel.newPostFor(GeohashId(it)) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/HashtagPostScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/HashtagPostScreen.kt index 59d4e8f8f..669cc05fc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/HashtagPostScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/HashtagPostScreen.kt @@ -53,7 +53,7 @@ fun HashtagPostScreen( val context = LocalContext.current - LaunchedEffect(Unit) { + LaunchedEffect(postViewModel, accountViewModel) { hashtag?.let { postViewModel.newPostFor(HashtagId(it)) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt index ec309dcfd..c9821ec97 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt @@ -99,7 +99,7 @@ import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.delay -import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext @OptIn(ExperimentalMaterial3Api::class, FlowPreview::class) @Composable @@ -120,13 +120,13 @@ fun ShortNotePostScreen( val context = LocalContext.current val activity = context.getActivity() - LaunchedEffect(Unit) { - launch(Dispatchers.IO) { - postViewModel.load(baseReplyTo, quote, fork, version, draft) - message?.ifBlank { null }?.let { - postViewModel.updateMessage(TextFieldValue(it)) - } - attachment?.let { + LaunchedEffect(postViewModel, accountViewModel) { + postViewModel.load(baseReplyTo, quote, fork, version, draft) + message?.ifBlank { null }?.let { + postViewModel.updateMessage(TextFieldValue(it)) + } + attachment?.let { + withContext(Dispatchers.IO) { val mediaType = context.contentResolver.getType(it) postViewModel.selectImage(persistentListOf(SelectedMedia(it, mediaType))) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt index 29fa178c2..59d03e1c8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt @@ -111,7 +111,7 @@ fun NewPublicMessageScreen( val postViewModel: NewPublicMessageViewModel = viewModel() postViewModel.init(accountViewModel) - LaunchedEffect(Unit) { + LaunchedEffect(postViewModel, accountViewModel) { withContext(Dispatchers.IO) { to?.let { postViewModel.load(it) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/dm/AddDMRelayListDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/dm/AddDMRelayListDialog.kt index 3f8df123f..20038d00d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/dm/AddDMRelayListDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/dm/AddDMRelayListDialog.kt @@ -59,7 +59,7 @@ fun AddDMRelayListDialog( postViewModel.init(accountViewModel) - LaunchedEffect(postViewModel, accountViewModel.account) { + LaunchedEffect(postViewModel, accountViewModel) { postViewModel.load() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt index 8329b0b94..1eab153c2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt @@ -112,7 +112,7 @@ fun LoginPage( val loginViewModel: LoginViewModel = viewModel() loginViewModel.init(accountStateViewModel) - LaunchedEffect(Unit) { + LaunchedEffect(loginViewModel, isFirstLogin, newAccountKey) { loginViewModel.load(isFirstLogin, newAccountKey) }