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)
|
||||
self.model.refreshItemsContainingAddress(args.address)
|
||||
|
||||
events.on(SIGNAL_TOKENS_LIST_UPDATED) do(e:Args):
|
||||
self.model.refreshAmountCurrency(self.currencyService)
|
||||
|
||||
# setup other event handlers
|
||||
self.eventsHandler.onFilteringDone(proc (jsonObj: JsonNode) =
|
||||
self.processResponse(jsonObj)
|
||||
|
|
|
@ -88,17 +88,29 @@ QtObject:
|
|||
if metadata.symbolOut.isSome() or metadata.amountOut > 0:
|
||||
result.outAmount = currencyService.parseCurrencyValue(metadata.symbolOut.get(""), metadata.amountOut)
|
||||
|
||||
proc newActivityEntry*(backendEntry: backend.ActivityEntry, addresses: seq[string], currencyService: Service): ActivityEntry =
|
||||
var ae: entry.ActivityEntry
|
||||
proc buildExtraData(backendEntry: backend.ActivityEntry, currencyService: Service): ExtraData =
|
||||
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():
|
||||
of MultiTransaction:
|
||||
let extraData = buildMultiTransactionExtraData(backendEntry, currencyService)
|
||||
ae = newMultiTransactionActivityEntry(backendEntry, extraData, currencyService)
|
||||
of SimpleTransaction, PendingTransaction:
|
||||
let extraData = buildTransactionExtraData(backendEntry, currencyService)
|
||||
ae = newTransactionActivityEntry(backendEntry, addresses, extraData, currencyService)
|
||||
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.} =
|
||||
return self.metadata.getPayloadType() == backend.PayloadType.MultiTransaction
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import NimQml, Tables, strutils, stew/shims/strformat, sequtils, logging, option
|
|||
import ./entry
|
||||
|
||||
import app/modules/shared_models/currency_amount
|
||||
import app_service/service/currency/service
|
||||
import backend/activity as backend
|
||||
import backend/backend as importing_transactionidentity_comp
|
||||
|
||||
|
@ -154,3 +155,7 @@ QtObject:
|
|||
let index = self.createIndex(i, 0, nil)
|
||||
defer: index.delete
|
||||
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