diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt index a8d4ef0..c18118f 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt @@ -68,7 +68,7 @@ fun TransferMoneyDialog( } - val recipientFinder = RecipientFinder(DI.bankFinder) + val recipientFinder = remember { RecipientFinder(DI.bankFinder) } var isTransferringMoney by remember { mutableStateOf(false) } @@ -77,14 +77,11 @@ fun TransferMoneyDialog( val verticalSpace = 8.dp + var isInitialized by remember { mutableStateOf(false) } + val coroutineScope = rememberCoroutineScope() - coroutineScope.launch { - recipientFinder.updateData(bankingService.getAllAccountTransactions()) // only a bit problematic: if in the meantime new transactions are retrieved, then RecipientFinder doesn't contain the newly retrieved transactions - } - - fun confirmCalled() { isTransferringMoney = true @@ -229,4 +226,15 @@ fun TransferMoneyDialog( } } } + + + LaunchedEffect(isInitialized) { + if (isInitialized == false) { + isInitialized = true + + coroutineScope.launch { + recipientFinder.updateData(bankingService.getAllAccountTransactions()) // only a bit problematic: if in the meantime new transactions are retrieved, then RecipientFinder doesn't contain the newly retrieved transactions + } + } + } } \ No newline at end of file