mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-22 19:48:52 +00:00
fix: fix settings not being refetched when they had been edited before
This commit is contained in:
parent
e1a4a47636
commit
2a9f9118a1
@ -321,8 +321,8 @@ QtObject:
|
||||
write = setDefaultCurrency
|
||||
notify = defaultCurrencyChanged
|
||||
|
||||
proc hasAsset*(self: WalletView, account: string, symbol: string): bool {.slot.} =
|
||||
self.status.wallet.hasAsset(account, symbol)
|
||||
proc hasAsset*(self: WalletView, symbol: string): bool {.slot.} =
|
||||
self.status.wallet.hasAsset(symbol)
|
||||
|
||||
proc toggleAsset*(self: WalletView, symbol: string) {.slot.} =
|
||||
self.status.wallet.toggleAsset(symbol)
|
||||
|
@ -23,9 +23,9 @@ proc saveSetting*(key: Setting, value: string | JsonNode): StatusGoError =
|
||||
if responseResult == "null":
|
||||
result.error = ""
|
||||
else: result = Json.decode(response, StatusGoError)
|
||||
dirty.store(true)
|
||||
except Exception as e:
|
||||
error "Error saving setting", key=key, value=value, msg=e.msg
|
||||
dirty.store(true)
|
||||
|
||||
proc getWeb3ClientVersion*(): string =
|
||||
parseJson(callPrivateRPC("web3_clientVersion"))["result"].getStr
|
||||
|
@ -47,7 +47,15 @@ proc visibleTokensSNTDefault(): JsonNode =
|
||||
|
||||
return response
|
||||
|
||||
proc toggleAsset*(symbol: string) =
|
||||
proc convertStringSeqToERC20ContractSeq*(stringSeq: seq[string]): seq[Erc20Contract] =
|
||||
result = @[]
|
||||
for v in stringSeq:
|
||||
let t = getErc20Contract(v)
|
||||
if t != nil: result.add t
|
||||
let ct = customTokens.getErc20ContractBySymbol(v)
|
||||
if ct != nil: result.add ct
|
||||
|
||||
proc toggleAsset*(symbol: string): seq[Erc20Contract] =
|
||||
let currentNetwork = getCurrentNetwork()
|
||||
let visibleTokens = visibleTokensSNTDefault()
|
||||
var visibleTokenList = visibleTokens[$currentNetwork].to(seq[string])
|
||||
@ -58,7 +66,9 @@ proc toggleAsset*(symbol: string) =
|
||||
visibleTokenList.add symbol
|
||||
visibleTokens[$currentNetwork] = newJArray()
|
||||
visibleTokens[$currentNetwork] = %* visibleTokenList
|
||||
discard saveSetting(Setting.VisibleTokens, $visibleTokens)
|
||||
let saved = saveSetting(Setting.VisibleTokens, $visibleTokens)
|
||||
|
||||
convertStringSeqToERC20ContractSeq(visibleTokenList)
|
||||
|
||||
proc hideAsset*(symbol: string) =
|
||||
let currentNetwork = getCurrentNetwork()
|
||||
@ -77,12 +87,7 @@ proc getVisibleTokens*(): seq[Erc20Contract] =
|
||||
var visibleTokenList = visibleTokens[$currentNetwork].to(seq[string])
|
||||
let customTokens = getCustomTokens()
|
||||
|
||||
result = @[]
|
||||
for v in visibleTokenList:
|
||||
let t = getErc20Contract(v)
|
||||
if t != nil: result.add t
|
||||
let ct = customTokens.getErc20ContractBySymbol(v)
|
||||
if ct != nil: result.add ct
|
||||
result = convertStringSeqToERC20ContractSeq(visibleTokenList)
|
||||
|
||||
proc addCustomToken*(address: string, name: string, symbol: string, decimals: int, color: string) =
|
||||
let payload = %* [{"address": address, "name": name, "symbol": symbol, "decimals": decimals, "color": color}]
|
||||
|
@ -290,8 +290,7 @@ proc addWatchOnlyAccount*(self: WalletModel, address: string, accountName: strin
|
||||
let account = GeneratedAccount(address: address)
|
||||
return self.addNewGeneratedAccount(account, "", accountName, color, constants.WATCH, false)
|
||||
|
||||
proc hasAsset*(self: WalletModel, account: string, symbol: string): bool =
|
||||
self.tokens = status_tokens.getVisibleTokens()
|
||||
proc hasAsset*(self: WalletModel, symbol: string): bool =
|
||||
self.tokens.anyIt(it.symbol == symbol)
|
||||
|
||||
proc changeAccountSettings*(self: WalletModel, address: string, accountName: string, color: string): string =
|
||||
@ -311,8 +310,7 @@ proc deleteAccount*(self: WalletModel, address: string): string =
|
||||
result = status_accounts.deleteAccount(address)
|
||||
|
||||
proc toggleAsset*(self: WalletModel, symbol: string) =
|
||||
status_tokens.toggleAsset(symbol)
|
||||
self.tokens = status_tokens.getVisibleTokens()
|
||||
self.tokens = status_tokens.toggleAsset(symbol)
|
||||
for account in self.accounts:
|
||||
account.assetList = self.generateAccountConfiguredAssets(account.address)
|
||||
updateBalance(account, self.getDefaultCurrency())
|
||||
|
@ -62,7 +62,7 @@ Item {
|
||||
}
|
||||
StatusCheckBox {
|
||||
id: assetCheck
|
||||
checked: walletModel.hasAsset("0x123", symbol)
|
||||
checked: walletModel.hasAsset(symbol)
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Style.current.smallPadding
|
||||
onClicked: walletModel.toggleAsset(symbol)
|
||||
|
Loading…
x
Reference in New Issue
Block a user