Skip to content

Commit

Permalink
We are now loading accounts with balance information, and accordingly…
Browse files Browse the repository at this point in the history
… we receive updates

Thus we check for first load.
  • Loading branch information
mtotschnig committed Oct 16, 2024
1 parent c089413 commit a30de8f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ open class ExpenseEdit : AmountActivity<TransactionEditViewModel>(), ContribIFac
abortWithMessage(getString(R.string.dialog_command_disabled_insert_transfer))
} else {
if (::delegate.isInitialized) {
delegate.setAccounts(accounts)
delegate.setAccounts(accounts, !accountsLoaded)
loadDebts()
accountsLoaded = true
if (mIsResumed) setupListeners()
Expand All @@ -741,10 +741,13 @@ open class ExpenseEdit : AmountActivity<TransactionEditViewModel>(), ContribIFac
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.accounts.collect {
val firstLoad = !accountsLoaded
setAccounts(it)
collectSplitParts()
if (isSplitParent) {
viewModel.loadSplitParts(delegate.rowId, isTemplate)
if (firstLoad) {
collectSplitParts()
if (isSplitParent) {
viewModel.loadSplitParts(delegate.rowId, isTemplate)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -993,18 +993,19 @@ abstract class TransactionDelegate<T : ITransaction>(
updateAccount(mAccounts[selected])
}

open fun setAccounts(data: List<Account>) {
open fun setAccounts(data: List<Account>, firstLoad: Boolean) {
mAccounts.clear()
mAccounts.addAll(data)
accountSpinner.adapter = IdAdapter(context, data).apply {
setDropDownViewResource(androidx.appcompat.R.layout.support_simple_spinner_dropdown_item)
}

viewBinding.Amount.setTypeEnabled(true)
isProcessingLinkedAmountInputs = true
configureType()
isProcessingLinkedAmountInputs = false
setAccount()
if (firstLoad) {
viewBinding.Amount.setTypeEnabled(true)
isProcessingLinkedAmountInputs = true
configureType()
isProcessingLinkedAmountInputs = false
setAccount()
}
}

private fun configureStatusSpinner() {
Expand Down

0 comments on commit a30de8f

Please sign in to comment.