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-27 21:26:26 +00:00
|
|
|
historyView.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
|
2023-01-03 09:24:04 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
2022-09-01 15:34:27 +00:00
|
|
|
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()
|
2023-01-03 09:24:04 +00:00
|
|
|
loading: isLoading
|
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
|
2023-01-12 22:39:46 +00:00
|
|
|
title: modelData !== undefined && !!modelData ? LocaleUtils.formatDate(modelData.timestamp * 1000, Locale.ShortFormat) : ""
|
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 {
|
2023-01-08 22:23:51 +00:00
|
|
|
property bool modelDataValid: modelData !== undefined && !!modelData
|
|
|
|
isIncoming: modelDataValid ? modelData.to === account.address: false
|
2023-01-17 20:05:21 +00:00
|
|
|
cryptoValue: modelDataValid ? modelData.value : undefined
|
|
|
|
fiatValue: modelDataValid ? RootStore.getFiatValue(cryptoValue.amount, symbol, RootStore.currentCurrency) : undefined
|
2023-01-08 22:23:51 +00:00
|
|
|
networkIcon: modelDataValid ? RootStore.getNetworkIcon(modelData.chainId) : ""
|
|
|
|
networkColor: modelDataValid ? RootStore.getNetworkColor(modelData.chainId) : ""
|
|
|
|
networkName: modelDataValid ? RootStore.getNetworkShortName(modelData.chainId) : ""
|
2023-01-17 20:05:21 +00:00
|
|
|
symbol: modelDataValid ? modelData.symbol : ""
|
2023-01-08 22:23:51 +00:00
|
|
|
transferStatus: modelDataValid ? RootStore.hex2Dec(modelData.txStatus) : ""
|
|
|
|
shortTimeStamp: modelDataValid ? LocaleUtils.formatTime(modelData.timestamp * 1000, Locale.ShortFormat) : ""
|
|
|
|
savedAddressName: modelDataValid ? RootStore.getNameForSavedWalletAddress(modelData.to) : ""
|
2022-09-05 09:15:47 +00:00
|
|
|
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
|
|
|
}
|