Fixed initializing RecipientFinder (which is quite expensive) only once

This commit is contained in:
dankito 2024-09-06 15:00:02 +02:00
parent 89b700b740
commit 77c944d33b
1 changed files with 14 additions and 6 deletions

View File

@ -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
}
}
}
}