fix: transaction history handling
- Determine if the recent transaction history is being fetched or available before obtaining the first 20 transactions - On account change, reset the selected tab to show the asset list - Collectibles were kinda pixelated/blurry (not anymore) Fixes #806
This commit is contained in:
parent
c334127179
commit
98aaa69e9d
|
@ -47,9 +47,15 @@ proc init*(self: WalletController) =
|
|||
|
||||
self.status.events.on(SignalType.Wallet.event) do(e:Args):
|
||||
var data = WalletSignal(e)
|
||||
if data.eventType == "newblock":
|
||||
case data.eventType:
|
||||
of "newblock":
|
||||
for acc in data.accounts:
|
||||
self.status.wallet.updateAccount(acc)
|
||||
# TODO: show notification
|
||||
# TODO: data.eventType == history, reorg, recent-history-fetching, recent-history-ready:
|
||||
of "recent-history-fetching":
|
||||
self.view.setHistoryFetchState(data.accounts, true)
|
||||
of "recent-history-ready":
|
||||
self.view.setHistoryFetchState(data.accounts, false)
|
||||
|
||||
# TODO: handle these data.eventType: history, reorg
|
||||
# see status-react/src/status_im/ethereum/subscriptions.cljs
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import NimQml, Tables, strformat, strutils, chronicles, json, std/wrapnils, parseUtils, stint
|
||||
import NimQml, Tables, strformat, strutils, chronicles, json, std/wrapnils, parseUtils, stint, tables
|
||||
import ../../status/[status, wallet, threads]
|
||||
import ../../status/wallet/collectibles as status_collectibles
|
||||
import ../../status/libstatus/wallet as status_wallet
|
||||
|
@ -25,6 +25,7 @@ QtObject:
|
|||
fastestGasPrice: string
|
||||
defaultGasLimit: string
|
||||
signingPhrase: string
|
||||
fetchingHistoryState: Table[string, bool]
|
||||
|
||||
proc delete(self: WalletView) =
|
||||
self.accounts.delete
|
||||
|
@ -54,6 +55,7 @@ QtObject:
|
|||
result.fastestGasPrice = "0"
|
||||
result.defaultGasLimit = "21000"
|
||||
result.signingPhrase = ""
|
||||
result.fetchingHistoryState = initTable[string, bool]()
|
||||
result.setup
|
||||
|
||||
proc etherscanLinkChanged*(self: WalletView) {.signal.}
|
||||
|
@ -115,8 +117,6 @@ QtObject:
|
|||
notify = currentTransactionsChanged
|
||||
|
||||
proc loadCollectiblesForAccount*(self: WalletView, address: string, currentCollectiblesList: seq[CollectibleList])
|
||||
proc loadTransactionsForAccount*(self: WalletView, address: string)
|
||||
|
||||
proc currentAccountChanged*(self: WalletView) {.signal.}
|
||||
|
||||
proc setCurrentAccountByIndex*(self: WalletView, index: int) {.slot.} =
|
||||
|
@ -132,9 +132,7 @@ QtObject:
|
|||
self.setCurrentCollectiblesLists(selectedAccount.collectiblesLists)
|
||||
self.loadCollectiblesForAccount(selectedAccount.address, selectedAccount.collectiblesLists)
|
||||
|
||||
# Display currently known transactions, and get latest transactions from status-go
|
||||
self.setCurrentTransactions(selectedAccount.transactions)
|
||||
self.loadTransactionsForAccount(selectedAccount.address)
|
||||
|
||||
proc getCurrentAccount*(self: WalletView): QVariant {.slot.} =
|
||||
result = newQVariant(self.currentAccount)
|
||||
|
@ -390,28 +388,6 @@ QtObject:
|
|||
|
||||
self.currentCollectiblesLists.setLoadingByType(collectibleType, 1)
|
||||
|
||||
|
||||
proc loadingTrxHistory*(self: WalletView, isLoading: bool) {.signal.}
|
||||
|
||||
proc loadTransactionsForAccount*(self: WalletView, address: string) {.slot.} =
|
||||
self.loadingTrxHistory(true)
|
||||
spawnAndSend(self, "setTrxHistoryResult") do:
|
||||
$(%*{
|
||||
"address": address,
|
||||
"history": getTransfersByAddress(address)
|
||||
})
|
||||
|
||||
proc setTrxHistoryResult(self: WalletView, historyJSON: string) {.slot.} =
|
||||
let historyData = parseJson(historyJSON)
|
||||
let transactions = historyData["history"].to(seq[Transaction]);
|
||||
let address = historyData["address"].getStr
|
||||
let index = self.accounts.getAccountindexByAddress(address)
|
||||
if index == -1: return
|
||||
self.accounts.getAccount(index).transactions = transactions
|
||||
if address == self.currentAccount.address:
|
||||
self.setCurrentTransactions(transactions)
|
||||
self.loadingTrxHistory(false)
|
||||
|
||||
proc gasPricePredictionsChanged*(self: WalletView) {.signal.}
|
||||
|
||||
proc getGasPricePredictions*(self: WalletView) {.slot.} =
|
||||
|
@ -462,3 +438,35 @@ QtObject:
|
|||
|
||||
QtProperty[QVariant] defaultTokenList:
|
||||
read = getDefaultTokenList
|
||||
proc historyWasFetched*(self: WalletView) {.signal.}
|
||||
|
||||
proc setHistoryFetchState*(self: WalletView, accounts: seq[string], isFetching: bool) =
|
||||
for acc in accounts:
|
||||
self.fetchingHistoryState[acc] = isFetching
|
||||
if not isFetching: self.historyWasFetched()
|
||||
|
||||
proc isFetchingHistory*(self: WalletView, address: string): bool {.slot.} =
|
||||
if self.fetchingHistoryState.hasKey(address):
|
||||
return self.fetchingHistoryState[address]
|
||||
return true
|
||||
|
||||
proc loadingTrxHistory*(self: WalletView, isLoading: bool) {.signal.}
|
||||
|
||||
proc loadTransactionsForAccount*(self: WalletView, address: string) {.slot.} =
|
||||
self.loadingTrxHistory(true)
|
||||
spawnAndSend(self, "setTrxHistoryResult") do:
|
||||
$(%*{
|
||||
"address": address,
|
||||
"history": getTransfersByAddress(address)
|
||||
})
|
||||
|
||||
proc setTrxHistoryResult(self: WalletView, historyJSON: string) {.slot.} =
|
||||
let historyData = parseJson(historyJSON)
|
||||
let transactions = historyData["history"].to(seq[Transaction]);
|
||||
let address = historyData["address"].getStr
|
||||
let index = self.accounts.getAccountindexByAddress(address)
|
||||
if index == -1: return
|
||||
self.accounts.getAccount(index).transactions = transactions
|
||||
if address == self.currentAccount.address:
|
||||
self.setCurrentTransactions(transactions)
|
||||
self.loadingTrxHistory(false)
|
||||
|
|
|
@ -5,6 +5,14 @@ import "../../../imports"
|
|||
import "../../../shared"
|
||||
|
||||
Item {
|
||||
function checkIfHistoryIsBeingFetched(){
|
||||
if(walletModel.isFetchingHistory(walletModel.currentAccount.address)){
|
||||
loadingImg.active = true;
|
||||
} else {
|
||||
walletModel.loadTransactionsForAccount(walletModel.currentAccount.address)
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: loadingImg
|
||||
active: false
|
||||
|
@ -22,6 +30,7 @@ Item {
|
|||
|
||||
Connections {
|
||||
target: walletModel
|
||||
onHistoryWasFetched: checkIfHistoryIsBeingFetched()
|
||||
onLoadingTrxHistory: {
|
||||
loadingImg.active = isLoading
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ Item {
|
|||
}
|
||||
selectedAccount = newIndex
|
||||
walletModel.setCurrentAccountByIndex(newIndex)
|
||||
walletTabBar.currentIndex = 0;
|
||||
}
|
||||
id: walletInfoContainer
|
||||
|
||||
|
|
|
@ -87,9 +87,7 @@ SplitView {
|
|||
anchors.leftMargin: 32
|
||||
//% "History"
|
||||
btnText: qsTrId("history")
|
||||
onClicked: {
|
||||
walletModel.loadTransactionsForAccount(walletModel.currentAccount.address)
|
||||
}
|
||||
onClicked: historyTab.checkIfHistoryIsBeingFetched()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,8 @@ ScrollView {
|
|||
height: root.imageSize
|
||||
z: 1
|
||||
source: modelData.image
|
||||
sourceSize.width: width
|
||||
sourceSize.height: height
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
|
|
@ -18,6 +18,8 @@ Item {
|
|||
height: 248
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
source: root.collectibleImage
|
||||
sourceSize.width: width
|
||||
sourceSize.height: height
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7d8edc6db225057af5592e2f20c7470fac83fbaf
|
||||
Subproject commit d663d22df625837f329aebd038d2b2e003c4dccb
|
|
@ -1 +1 @@
|
|||
Subproject commit 8a013591bda4c5357154207060e62b5cc1eff6c8
|
||||
Subproject commit 474bdbf49cf1634ba504888ad1a1927a2703bd3f
|
|
@ -1 +1 @@
|
|||
Subproject commit 32b86bfd1ff97764e94447675559bf37a4ffb407
|
||||
Subproject commit 1db43c7234acb9554e3e80bf2e7b61c4cf0435cf
|
|
@ -1 +1 @@
|
|||
Subproject commit 767c8e0fb433da5276c4ac3e61b3360e003536a7
|
||||
Subproject commit a8cafce7c0d16c3c5a0d928b4a0e31207d399de0
|
|
@ -1 +1 @@
|
|||
Subproject commit 57d6e6459daab1d357adafcbf7cb008f5b8969e5
|
||||
Subproject commit d48ed1ea37a800793ed756ac5a69628d920b1dc0
|
Loading…
Reference in New Issue