fix(Swap): Fixing the account balance in the swap modal
The root cause of this issue is the improper computation of the `accountBalance` expression role in the accounts model. Its value depends on another model (`filteredBalancesModel`) and by the time the expression role gets computed the proper `balance ` is not ready in the `filteredBalancesModel`. This is a quick fix, but maybe the real fix should be restructuring the adapter and the model dependencies. I'd look out for any `ModelUtils` usage and replace it with a declarative approach if possible.
This commit is contained in:
parent
73bcacbfc0
commit
9f40f0fada
|
@ -442,7 +442,7 @@ StatusDialog {
|
|||
accountAddress: root.swapAdaptor.selectedAccount.address
|
||||
accountEmoji: root.swapAdaptor.selectedAccount.emoji
|
||||
accountColor: Utils.getColorForId(root.swapAdaptor.selectedAccount.colorId)
|
||||
accountBalanceFormatted: payPanel.accountBalanceFormatted // FIXME https://github.com/status-im/status-desktop/issues/15554
|
||||
accountBalanceFormatted: root.swapAdaptor.selectedAccount.accountBalance.formattedBalance
|
||||
|
||||
networkShortName: networkFilter.singleSelectionItemData.shortName
|
||||
networkName: networkFilter.singleSelectionItemData.chainName
|
||||
|
|
|
@ -38,6 +38,7 @@ QObject {
|
|||
// Probably this data transformation should live there since they have common base.
|
||||
readonly property var nonWatchAccounts: SortFilterProxyModel {
|
||||
sourceModel: root.swapStore.accounts
|
||||
delayed: true // Delayed to allow `processAccountBalance` dependencies to be resolved
|
||||
filters: ValueFilter {
|
||||
roleName: "canSend"
|
||||
value: true
|
||||
|
@ -49,7 +50,17 @@ QObject {
|
|||
proxyRoles: [
|
||||
FastExpressionRole {
|
||||
name: "accountBalance"
|
||||
expression: d.processAccountBalance(model.address)
|
||||
expression: {
|
||||
// dependencies
|
||||
root.swapFormData.fromTokensKey
|
||||
root.fromToken
|
||||
root.fromToken.symbol
|
||||
root.fromToken.decimals
|
||||
root.swapFormData.selectedNetworkChainId
|
||||
root.swapFormData.fromTokensKey
|
||||
|
||||
return d.processAccountBalance(model.address)
|
||||
}
|
||||
expectedRoles: ["address"]
|
||||
},
|
||||
FastExpressionRole {
|
||||
|
|
Loading…
Reference in New Issue