fix(wallet): Update currency format on startup (#14623)
This commit is contained in:
parent
27c53f4154
commit
8049eaa014
|
@ -244,6 +244,9 @@ QtObject:
|
||||||
let args = SavedAddressArgs(e)
|
let args = SavedAddressArgs(e)
|
||||||
self.model.refreshItemsContainingAddress(args.address)
|
self.model.refreshItemsContainingAddress(args.address)
|
||||||
|
|
||||||
|
events.on(SIGNAL_TOKENS_LIST_UPDATED) do(e:Args):
|
||||||
|
self.model.refreshAmountCurrency(self.currencyService)
|
||||||
|
|
||||||
# setup other event handlers
|
# setup other event handlers
|
||||||
self.eventsHandler.onFilteringDone(proc (jsonObj: JsonNode) =
|
self.eventsHandler.onFilteringDone(proc (jsonObj: JsonNode) =
|
||||||
self.processResponse(jsonObj)
|
self.processResponse(jsonObj)
|
||||||
|
|
|
@ -88,17 +88,29 @@ QtObject:
|
||||||
if metadata.symbolOut.isSome() or metadata.amountOut > 0:
|
if metadata.symbolOut.isSome() or metadata.amountOut > 0:
|
||||||
result.outAmount = currencyService.parseCurrencyValue(metadata.symbolOut.get(""), metadata.amountOut)
|
result.outAmount = currencyService.parseCurrencyValue(metadata.symbolOut.get(""), metadata.amountOut)
|
||||||
|
|
||||||
proc newActivityEntry*(backendEntry: backend.ActivityEntry, addresses: seq[string], currencyService: Service): ActivityEntry =
|
proc buildExtraData(backendEntry: backend.ActivityEntry, currencyService: Service): ExtraData =
|
||||||
var ae: entry.ActivityEntry
|
var extraData: ExtraData
|
||||||
|
case backendEntry.getPayloadType():
|
||||||
|
of MultiTransaction:
|
||||||
|
extraData = buildMultiTransactionExtraData(backendEntry, currencyService)
|
||||||
|
of SimpleTransaction, PendingTransaction:
|
||||||
|
extraData = buildTransactionExtraData(backendEntry, currencyService)
|
||||||
|
return extraData
|
||||||
|
|
||||||
|
proc newActivityEntry*(backendEntry: backend.ActivityEntry, addresses: seq[string], currencyService: Service): ActivityEntry =
|
||||||
|
var ae: entry.ActivityEntry
|
||||||
|
let extraData = buildExtraData(backendEntry, currencyService)
|
||||||
case backendEntry.getPayloadType():
|
case backendEntry.getPayloadType():
|
||||||
of MultiTransaction:
|
of MultiTransaction:
|
||||||
let extraData = buildMultiTransactionExtraData(backendEntry, currencyService)
|
|
||||||
ae = newMultiTransactionActivityEntry(backendEntry, extraData, currencyService)
|
ae = newMultiTransactionActivityEntry(backendEntry, extraData, currencyService)
|
||||||
of SimpleTransaction, PendingTransaction:
|
of SimpleTransaction, PendingTransaction:
|
||||||
let extraData = buildTransactionExtraData(backendEntry, currencyService)
|
|
||||||
ae = newTransactionActivityEntry(backendEntry, addresses, extraData, currencyService)
|
ae = newTransactionActivityEntry(backendEntry, addresses, extraData, currencyService)
|
||||||
return ae
|
return ae
|
||||||
|
|
||||||
|
proc resetAmountCurrency*(self: ActivityEntry, service: Service) =
|
||||||
|
self.extraData = buildExtraData(self.metadata, service)
|
||||||
|
self.amountCurrency = self.extractCurrencyAmount(service)
|
||||||
|
|
||||||
proc isMultiTransaction*(self: ActivityEntry): bool {.slot.} =
|
proc isMultiTransaction*(self: ActivityEntry): bool {.slot.} =
|
||||||
return self.metadata.getPayloadType() == backend.PayloadType.MultiTransaction
|
return self.metadata.getPayloadType() == backend.PayloadType.MultiTransaction
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import NimQml, Tables, strutils, stew/shims/strformat, sequtils, logging, option
|
||||||
import ./entry
|
import ./entry
|
||||||
|
|
||||||
import app/modules/shared_models/currency_amount
|
import app/modules/shared_models/currency_amount
|
||||||
|
import app_service/service/currency/service
|
||||||
import backend/activity as backend
|
import backend/activity as backend
|
||||||
import backend/backend as importing_transactionidentity_comp
|
import backend/backend as importing_transactionidentity_comp
|
||||||
|
|
||||||
|
@ -153,4 +154,8 @@ QtObject:
|
||||||
cmpIgnoreCase(self.entries[i].getRecipient(), address) == 0:
|
cmpIgnoreCase(self.entries[i].getRecipient(), address) == 0:
|
||||||
let index = self.createIndex(i, 0, nil)
|
let index = self.createIndex(i, 0, nil)
|
||||||
defer: index.delete
|
defer: index.delete
|
||||||
self.dataChanged(index, index, @[ModelRole.ActivityEntryRole.int])
|
self.dataChanged(index, index, @[ModelRole.ActivityEntryRole.int])
|
||||||
|
|
||||||
|
proc refreshAmountCurrency*(self: Model, currencyService: Service) =
|
||||||
|
for i in 0..self.entries.high:
|
||||||
|
self.entries[i].resetAmountCurrency(currencyService)
|
Loading…
Reference in New Issue