fix(@desktop/wallet): Preferred network doesn't reflect in advanced view

fixes #9456
This commit is contained in:
Khushboo Mehta 2023-02-07 23:28:41 +05:30 committed by Khushboo-dev-cpp
parent 79645b53ce
commit 4c0bd1058f
3 changed files with 16 additions and 9 deletions

View File

@ -373,7 +373,7 @@ Rectangle {
name: "default"
PropertyChanges {
target: root
color: disabled ? Theme.palette.baseColor4 : "transparent"
color: disabled ? Theme.palette.baseColor4 : Theme.palette.indirectColor1
}
PropertyChanges {
target: root
@ -447,7 +447,7 @@ Rectangle {
name: "error"
PropertyChanges {
target: root
color: disabled ? Theme.palette.baseColor4 : "transparent"
color: disabled ? Theme.palette.baseColor4 : Theme.palette.indirectColor1
}
PropertyChanges {
target: root
@ -520,7 +520,7 @@ Rectangle {
name: "unpreferred"
PropertyChanges {
target: root
color: disabled ? Theme.palette.baseColor4 : "transparent"
color: disabled ? Theme.palette.baseColor4 : Theme.palette.indirectColor1
}
PropertyChanges {
target: root

View File

@ -140,10 +140,12 @@ QtObject {
return networksModule.getMainnetChainId()
}
// We should move all this over to nim
function addPreferredChains(preferredchains, showUnpreferredNetworks) {
let tempPreferredChains = preferredChainIds
for(const chain of preferredchains) {
if(!preferredChainIds.includes(chain)) {
preferredChainIds.push(chain)
if(!tempPreferredChains.includes(chain)) {
tempPreferredChains.push(chain)
// remove from disabled accounts as it was added as preferred
addRemoveDisabledToChain(chain, false)
}
@ -151,13 +153,15 @@ QtObject {
// here we are trying to remove chains that are not preferred from the list and
// also disable them incase the showUnpreferredNetworks toggle is turned off
for(var i = 0; i < preferredChainIds.length; i++) {
if(!preferredchains.includes(preferredChainIds[i])) {
for(var i = 0; i < tempPreferredChains.length; i++) {
if(!preferredchains.includes(tempPreferredChains[i])) {
if(!showUnpreferredNetworks)
addRemoveDisabledToChain(preferredChainIds[i], true)
preferredChainIds.splice(i, 1)
addRemoveDisabledToChain(tempPreferredChains[i], true)
tempPreferredChains.splice(i, 1)
}
}
preferredChainIds = tempPreferredChains
}
function addUnpreferredChainsToDisabledChains() {

View File

@ -188,6 +188,7 @@ Item {
property int bentLine: 0
property double amountToReceive: 0
property var currencyAmountToReceive: root.getCryptoCurrencyAmount(amountToReceive)
property var preferredChains: store.preferredChainIds
property bool preferred: store.preferredChainIds.includes(model.chainId)
primaryText: model.chainName
secondaryText: LocaleUtils.currencyAmountToLocaleString(currencyAmountToReceive)
@ -221,6 +222,8 @@ Item {
root.reCalculateSuggestedRoute()
}
}
// Only needed until we move preferredChains to nim side
onPreferredChainsChanged: preferred = store.preferredChainIds.includes(model.chainId)
}
}
}