fix(wallet): fix balance chart to display chart for tokens
Replace missing methods calls of chart after it was replaced with a different component. Update chart on networks change. Fix data for all chains requested - both test and real networks. Fix some unrelated qml errors
This commit is contained in:
parent
248ba1c1c8
commit
2f9bf48856
|
@ -66,7 +66,8 @@ proc getFlatNetworks*(self: Service): var seq[NetworkItem] =
|
||||||
|
|
||||||
# passes networks based on users choice of test/mainnet
|
# passes networks based on users choice of test/mainnet
|
||||||
proc getCurrentNetworks*(self: Service): seq[NetworkItem] =
|
proc getCurrentNetworks*(self: Service): seq[NetworkItem] =
|
||||||
self.flatNetworks.filter(n => n.isTest == self.settingsService.areTestNetworksEnabled())
|
let testEnabled = self.settingsService.areTestNetworksEnabled()
|
||||||
|
self.flatNetworks.filter(n => n.isTest == testEnabled)
|
||||||
|
|
||||||
proc getCurrentNetworksChainIds*(self: Service): seq[int] =
|
proc getCurrentNetworksChainIds*(self: Service): seq[int] =
|
||||||
return self.getCurrentNetworks().map(n => n.chainId)
|
return self.getCurrentNetworks().map(n => n.chainId)
|
||||||
|
|
|
@ -9,16 +9,7 @@ proc tokenBalanceHistoryDataResolved*(self: Service, response: string) {.slot.}
|
||||||
))
|
))
|
||||||
|
|
||||||
proc fetchHistoricalBalanceForTokenAsJson*(self: Service, addresses: seq[string], tokenSymbol: string, currencySymbol: string, timeInterval: BalanceHistoryTimeInterval) =
|
proc fetchHistoricalBalanceForTokenAsJson*(self: Service, addresses: seq[string], tokenSymbol: string, currencySymbol: string, timeInterval: BalanceHistoryTimeInterval) =
|
||||||
# create an empty list of chain ids
|
var chainIds: seq[int] = self.networkService.getEnabledChainIds()
|
||||||
var chainIds: seq[int] = self.networkService.getCurrentNetworks().filter(n => n.isEnabled and n.nativeCurrencySymbol == tokenSymbol).map(n => n.chainId)
|
|
||||||
if chainIds.len == 0:
|
|
||||||
let tokenChainIds = self.tokenService.getFlatTokensList().filter(t => t.symbol == tokenSymbol and t.communityId.isEmptyOrWhitespace).map(t => t.chainID)
|
|
||||||
chainIds = concat(chainIds, tokenChainIds)
|
|
||||||
|
|
||||||
if chainIds.len == 0:
|
|
||||||
error "failed to find a network with the symbol", tokenSymbol
|
|
||||||
return
|
|
||||||
|
|
||||||
let arg = GetTokenBalanceHistoryDataTaskArg(
|
let arg = GetTokenBalanceHistoryDataTaskArg(
|
||||||
tptr: getTokenBalanceHistoryDataTask,
|
tptr: getTokenBalanceHistoryDataTask,
|
||||||
vptr: cast[ByteAddress](self.vptr),
|
vptr: cast[ByteAddress](self.vptr),
|
||||||
|
|
|
@ -537,6 +537,9 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function transactionType(transaction) {
|
function transactionType(transaction) {
|
||||||
|
if (!transaction)
|
||||||
|
return Constants.TransactionType.Send
|
||||||
|
|
||||||
// Cross chain Send to another recipient is not a bridge, though involves bridging
|
// Cross chain Send to another recipient is not a bridge, though involves bridging
|
||||||
if (transaction.txType == Constants.TransactionType.Bridge && transaction.sender !== transaction.recipient) {
|
if (transaction.txType == Constants.TransactionType.Bridge && transaction.sender !== transaction.recipient) {
|
||||||
if (root.showAllAccounts) {
|
if (root.showAllAccounts) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ Item {
|
||||||
property var networkConnectionStore
|
property var networkConnectionStore
|
||||||
property var allNetworksModel
|
property var allNetworksModel
|
||||||
property var networkFilters
|
property var networkFilters
|
||||||
|
onNetworkFiltersChanged: d.forceRefreshBalanceStore = true
|
||||||
/*required*/ property string address: ""
|
/*required*/ property string address: ""
|
||||||
property TokenBalanceHistoryStore balanceStore: TokenBalanceHistoryStore {}
|
property TokenBalanceHistoryStore balanceStore: TokenBalanceHistoryStore {}
|
||||||
|
|
||||||
|
@ -46,6 +47,8 @@ Item {
|
||||||
rightModel: root.allNetworksModel
|
rightModel: root.allNetworksModel
|
||||||
joinRole: "chainId"
|
joinRole: "chainId"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property bool forceRefreshBalanceStore: false
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
@ -174,7 +177,7 @@ Item {
|
||||||
graphDetail.selectedStore = graphDetail.selectedGraphType === AssetsDetailView.GraphType.Price ? d.marketValueStore : balanceStore
|
graphDetail.selectedStore = graphDetail.selectedGraphType === AssetsDetailView.GraphType.Price ? d.marketValueStore : balanceStore
|
||||||
}
|
}
|
||||||
|
|
||||||
chart.animateToNewData()
|
chart.refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property var dateToShortLabel: function (value) {
|
readonly property var dateToShortLabel: function (value) {
|
||||||
|
@ -312,7 +315,7 @@ Item {
|
||||||
let selectedTimeRangeEnum = balanceStore.timeRangeStrToEnum(graphDetail.selectedTimeRange)
|
let selectedTimeRangeEnum = balanceStore.timeRangeStrToEnum(graphDetail.selectedTimeRange)
|
||||||
|
|
||||||
let currencySymbol = RootStore.currencyStore.currentCurrency
|
let currencySymbol = RootStore.currencyStore.currentCurrency
|
||||||
if(!balanceStore.hasData(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum)) {
|
if(!balanceStore.hasData(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum) || d.forceRefreshBalanceStore) {
|
||||||
RootStore.fetchHistoricalBalanceForTokenAsJson(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum)
|
RootStore.fetchHistoricalBalanceForTokenAsJson(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,8 +323,9 @@ Item {
|
||||||
Connections {
|
Connections {
|
||||||
target: balanceStore
|
target: balanceStore
|
||||||
function onNewDataReady(address, tokenSymbol, currencySymbol, timeRange) {
|
function onNewDataReady(address, tokenSymbol, currencySymbol, timeRange) {
|
||||||
|
d.forceRefreshBalanceStore = false
|
||||||
if (timeRange === balanceStore.timeRangeStrToEnum(graphDetail.selectedTimeRange)) {
|
if (timeRange === balanceStore.timeRangeStrToEnum(graphDetail.selectedTimeRange)) {
|
||||||
chart.updateToNewData()
|
chart.refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ ColumnLayout {
|
||||||
proxyRoles: ExpressionRole {
|
proxyRoles: ExpressionRole {
|
||||||
name: "date"
|
name: "date"
|
||||||
expression: {
|
expression: {
|
||||||
if (model.activityEntry.timestamp === 0)
|
if (!model.activityEntry || model.activityEntry.timestamp === 0)
|
||||||
return ""
|
return ""
|
||||||
const currDate = new Date()
|
const currDate = new Date()
|
||||||
const timestampDate = new Date(model.activityEntry.timestamp * 1000)
|
const timestampDate = new Date(model.activityEntry.timestamp * 1000)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5059c19aae4afbd1bdc4fa07f93f37b70989b2c7
|
Subproject commit d07f9b5b162c078f71bf19a189e2e26c118a0db4
|
Loading…
Reference in New Issue