2021-10-05 20:50:22 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.1
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
import StatusQ.Core 0.1
|
2021-10-20 10:21:23 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2022-09-01 15:34:27 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-10-20 10:21:23 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2022-03-25 08:46:47 +00:00
|
|
|
import "../panels"
|
2021-10-05 20:50:22 +00:00
|
|
|
import "../popups"
|
|
|
|
import "../stores"
|
|
|
|
import "../controls"
|
|
|
|
|
2022-09-01 15:34:27 +00:00
|
|
|
ColumnLayout {
|
2021-10-05 20:50:22 +00:00
|
|
|
id: historyView
|
|
|
|
|
2022-03-25 08:46:47 +00:00
|
|
|
property var account
|
2021-10-05 20:50:22 +00:00
|
|
|
property int pageSize: 20 // number of transactions per page
|
2022-09-01 15:34:27 +00:00
|
|
|
property bool isLoading: false
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2022-09-05 09:15:47 +00:00
|
|
|
signal launchTransactionDetail(var transaction)
|
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
function fetchHistory() {
|
2022-03-25 08:46:47 +00:00
|
|
|
if (RootStore.isFetchingHistory(historyView.account.address)) {
|
2022-09-01 15:34:27 +00:00
|
|
|
isLoading = true
|
2021-10-05 20:50:22 +00:00
|
|
|
} else {
|
2022-03-25 08:46:47 +00:00
|
|
|
RootStore.loadTransactionsForAccount(historyView.account.address, pageSize)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
2021-10-21 08:22:05 +00:00
|
|
|
target: RootStore.history
|
2022-03-25 08:46:47 +00:00
|
|
|
onLoadingTrxHistoryChanged: function(isLoading, address) {
|
|
|
|
if (historyView.account.address.toLowerCase() === address.toLowerCase()) {
|
2022-09-20 12:27:52 +00:00
|
|
|
root.isLoading = isLoading
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-01 15:34:27 +00:00
|
|
|
Loader {
|
|
|
|
id: loadingImg
|
|
|
|
active: isLoading
|
|
|
|
sourceComponent: loadingImageComponent
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
|
|
|
Layout.rightMargin: Style.current.padding
|
|
|
|
}
|
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
StyledText {
|
|
|
|
id: nonArchivalNodeError
|
2022-09-01 15:34:27 +00:00
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
visible: RootStore.isNonArchivalNode
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Status Desktop is connected to a non-archival node. Transaction history may be incomplete.")
|
2021-10-05 20:50:22 +00:00
|
|
|
font.pixelSize: Style.current.primaryTextFontSize
|
|
|
|
color: Style.current.danger
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: noTxs
|
|
|
|
visible: transactionListRoot.count === 0
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("No transactions found")
|
2021-10-05 20:50:22 +00:00
|
|
|
font.pixelSize: Style.current.primaryTextFontSize
|
|
|
|
}
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2021-10-05 20:50:22 +00:00
|
|
|
id: transactionListRoot
|
2022-09-20 12:27:52 +00:00
|
|
|
objectName: "walletAccountTransactionList"
|
2022-09-01 15:34:27 +00:00
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
Layout.topMargin: nonArchivalNodeError.visible || noTxs.visible ? Style.current.padding : 0
|
|
|
|
Layout.bottomMargin: Style.current.padding
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
model: RootStore.historyTransactions
|
2022-09-01 15:34:27 +00:00
|
|
|
delegate: Loader {
|
|
|
|
width: parent.width
|
|
|
|
sourceComponent: isTimeStamp ? dateHeader : transactionDelegate
|
|
|
|
onLoaded: {
|
|
|
|
item.modelData = model
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2022-09-01 15:34:27 +00:00
|
|
|
ScrollBar.vertical: StatusScrollBar {}
|
|
|
|
|
|
|
|
footer: StatusButton {
|
|
|
|
id: loadMoreButton
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
text: qsTr("Load More")
|
|
|
|
// TODO: handle case when requested limit === transaction count -- there
|
|
|
|
// is currently no way to know that there are no more results
|
|
|
|
enabled: !isLoading && RootStore.historyTransactions.hasMore
|
|
|
|
onClicked: fetchHistory()
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
2022-09-01 15:34:27 +00:00
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2022-09-01 15:34:27 +00:00
|
|
|
Component {
|
|
|
|
id: dateHeader
|
|
|
|
StatusListItem {
|
|
|
|
property var modelData
|
|
|
|
height: 40
|
2022-09-05 09:15:47 +00:00
|
|
|
title: modelData !== undefined && !!modelData ? Utils.formatShortDate(modelData.timestamp * 1000, RootStore.accountSensitiveSettings.is24hTimeFormat) : ""
|
2022-09-01 15:34:27 +00:00
|
|
|
statusListItemTitle.color: Theme.palette.baseColor1
|
|
|
|
color: Theme.palette.statusListItem.backgroundColor
|
|
|
|
sensor.enabled: false
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-01 15:34:27 +00:00
|
|
|
Component {
|
|
|
|
id: transactionDelegate
|
|
|
|
TransactionDelegate {
|
2022-09-05 09:15:47 +00:00
|
|
|
isIncoming: modelData !== undefined && !!modelData ? modelData.to === account.address: false
|
2022-09-01 15:34:27 +00:00
|
|
|
currentCurrency: RootStore.currentCurrency
|
2022-09-05 09:15:47 +00:00
|
|
|
cryptoValue: modelData !== undefined && !!modelData ? RootStore.hex2Eth(modelData.value) : ""
|
2022-09-01 15:34:27 +00:00
|
|
|
fiatValue: RootStore.getFiatValue(cryptoValue, resolvedSymbol, RootStore.currentCurrency)
|
2022-09-05 09:15:47 +00:00
|
|
|
networkIcon: modelData !== undefined && !!modelData ? RootStore.getNetworkIcon(modelData.chainId) : ""
|
|
|
|
networkColor: modelData !== undefined && !!modelData ? RootStore.getNetworkColor(modelData.chainId) : ""
|
|
|
|
networkName: modelData !== undefined && !!modelData ? RootStore.getNetworkShortName(modelData.chainId) : ""
|
|
|
|
symbol: modelData !== undefined && !!modelData ? RootStore.findTokenSymbolByAddress(modelData.contract) : ""
|
|
|
|
transferStatus: modelData !== undefined && !!modelData ? RootStore.hex2Dec(modelData.txStatus) : ""
|
|
|
|
shortTimeStamp: modelData !== undefined && !!modelData ? Utils.formatShortTime(modelData.timestamp * 1000, RootStore.accountSensitiveSettings.is24hTimeFormat) : ""
|
|
|
|
savedAddressName: modelData !== undefined && !!modelData ? RootStore.getNameForSavedWalletAddress(modelData.to) : ""
|
|
|
|
onClicked: launchTransactionDetail(modelData)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-01 15:34:27 +00:00
|
|
|
Component {
|
|
|
|
id: loadingImageComponent
|
|
|
|
StatusLoadingIndicator {}
|
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|