ui: address page keeps auto-create and share state when covered

A page covered by another one is removed from composition and composed
again on Back, so the address page re-ran its auto-create effect and
reset "Share with contacts" to its parameter: after Delete address,
opening one of its pages and going back created the address again, and
after turning sharing on in Address settings the page showed it off.

The page now keeps both in its ModalData, and auto-creates only once.
This applies on both platforms, to every caller.
This commit is contained in:
Narasimha-sc committed 2026-10-18 09:52:04 +00:00
1 parent 813f914d3a
commit 04f156dbad
1 file changed
+7 -5
@@ -38,7 +38,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
@Composable
fun UserAddressView(
fun ModalData.UserAddressView(
chatModel: ChatModel,
shareViaProfile: Boolean = false,
autoCreateAddress: Boolean = false,
@@ -46,7 +46,7 @@ fun UserAddressView(
close: () -> Unit
) {
// TODO close when remote host changes
val shareViaProfile = remember { mutableStateOf(shareViaProfile) }
val shareViaProfile = remember { stateGetOrPut("shareViaProfile") { shareViaProfile } }
val progressIndicator = remember { mutableStateOf(false) }
val user = remember { chatModel.currentUser }
val clipboard = LocalClipboardManager.current
@@ -114,9 +114,11 @@ fun UserAddressView(
fun share(userAddress: String) { clipboard.shareText(userAddress) }
LaunchedEffect(autoCreateAddress) {
if (chatModel.userAddress.value == null && autoCreateAddress) {
createAddress()
val autoCreatePending = remember { stateGetOrPut("autoCreateAddress") { autoCreateAddress } }
LaunchedEffect(Unit) {
if (autoCreatePending.value) {
autoCreatePending.value = false
if (chatModel.userAddress.value == null) createAddress()
}
}
val userAddress = remember { chatModel.userAddress }