diff --git a/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml b/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml
index e761f3e510..b2b6f7b8fe 100644
--- a/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml
+++ b/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml
@@ -382,8 +382,8 @@ Item {
height: visible ? parent.height : 0;
AnonymousProRegular {
- id: dateText;
- text: model.created_at ? getFormattedDate(model.created_at * 1000) : "";
+ id: hfcText;
+ text: model.hfc_text;
// Style
size: 18;
anchors.left: parent.left;
@@ -391,23 +391,24 @@ Item {
anchors.topMargin: 15;
width: 118;
height: paintedHeight;
- color: hifi.colors.blueAccent;
wrapMode: Text.WordWrap;
+ font.bold: true;
// Alignment
horizontalAlignment: Text.AlignRight;
}
AnonymousProRegular {
id: transactionText;
- text: model.text ? (model.status === "invalidated" ? ("INVALIDATED: " + model.text) : model.text) : "";
+ text: model.transaction_text ? (model.status === "invalidated" ? ("INVALIDATED: " + model.transaction_text) : model.transaction_text) : "";
size: 18;
anchors.top: parent.top;
anchors.topMargin: 15;
- anchors.left: dateText.right;
+ anchors.left: hfcText.right;
anchors.leftMargin: 20;
anchors.right: parent.right;
height: paintedHeight;
color: model.status === "invalidated" ? hifi.colors.redAccent : hifi.colors.baseGrayHighlight;
+ linkColor: hifi.colors.blueAccent;
wrapMode: Text.WordWrap;
font.strikeout: model.status === "invalidated";
diff --git a/interface/src/commerce/Ledger.cpp b/interface/src/commerce/Ledger.cpp
index 269e8b5e06..ba27b397f8 100644
--- a/interface/src/commerce/Ledger.cpp
+++ b/interface/src/commerce/Ledger.cpp
@@ -118,30 +118,60 @@ void Ledger::inventory(const QStringList& keys) {
keysQuery("inventory", "inventorySuccess", "inventoryFailure");
}
-QString amountString(const QString& label, const QString&color, const QJsonValue& moneyValue, const QJsonValue& certsValue, const QJsonValue& usernameValue) {
- int money = moneyValue.toInt();
- int certs = certsValue.toInt();
- if (money <= 0 && certs <= 0) {
- return QString();
+QString hfcString(const QJsonValue& sentValue, const QJsonValue& receivedValue) {
+ int sent = sentValue.toInt();
+ int received = receivedValue.toInt();
+ if (sent <= 0 && received <= 0) {
+ return QString("-");
}
- QString result(QString(" %2").arg(color, label));
- if (money > 0) {
- result += QString(" %1 HFC").arg(money);
- }
- if (certs > 0) {
- if (money > 0) {
- result += QString(",");
+ QString result;
+ if (sent > 0) {
+ result += QString("-%1 HFC").arg(sent);
+ if (received > 0) {
+ result += QString("
");
}
- result += QString((certs == 1) ? " %1 certificate" : " %1 certificates").arg(certs);
}
- result += QString("");
+ if (received > 0) {
+ result += QString("%1 HFC").arg(received);
+ }
+ return result;
+}
+static const QString USER_PAGE_BASE_URL = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/users/";
+QString userLink(const QString& username) {
+ if (username.isEmpty()) {
+ return QString("someone");
+ }
+ return QString("%2").arg(USER_PAGE_BASE_URL, username);
+}
- // the only time we put the username in is when the money value is > 0
- // and the certificate value == 0, as we only want this for hfc transfers
- // Also - we don't bother if the username is 'highfidelity' or 'marketplace'
- if (money > 0 && certs == 0) {
- result += QString(" %1 %2").arg(label == "sent" ? "to" : "from", usernameValue.toString());
+QString transactionString(const QJsonObject& valueObject) {
+ int sentCerts = valueObject["sent_certs"].toInt();
+ int receivedCerts = valueObject["received_certs"].toInt();
+ int sent = valueObject["sent_money"].toInt();
+ int received = valueObject["received_money"].toInt();
+ int dateInteger = valueObject["created_at"].toInt();
+ QString message = valueObject["message"].toString();
+ QDateTime createdAt(QDateTime::fromSecsSinceEpoch(dateInteger, Qt::UTC));
+ QString result;
+
+ if (sentCerts <= 0 && receivedCerts <= 0) {
+ // this is an hfc transfer.
+ if (sent > 0) {
+ QString recipient = userLink(valueObject["recipient_name"].toString());
+ result += QString("Money sent to %1").arg(recipient);
+ } else {
+ QString sender = userLink(valueObject["sender_name"].toString());
+ result += QString("Money from %1").arg(sender);
+ }
+ if (!message.isEmpty()) {
+ result += QString("
with memo: \"%1\"").arg(message);
+ }
+ } else {
+ result += valueObject["message"].toString();
}
+ // no matter what we append a smaller date to the bottom of this...
+
+ result += QString("
%1").arg(createdAt.toLocalTime().toString());
return result;
}
@@ -165,16 +195,13 @@ void Ledger::historySuccess(QNetworkReply& reply) {
// TODO: do this with 0 copies if possible
for (auto it = historyArray.begin(); it != historyArray.end(); it++) {
+ // We have 2 text fields to synthesize, the one on the left is a listing
+ // of the HFC in/out of your wallet. The one on the right contains an explaination
+ // of the transaction. That could be just the memo (if it is a regular purchase), or
+ // more text (plus the optional memo) if an hfc transfer
auto valueObject = (*it).toObject();
- QString sent = amountString("sent", "EA4C5F", valueObject["sent_money"], valueObject["sent_certs"], valueObject["recipient_name"]);
- QString received = amountString("received", "1FC6A6", valueObject["received_money"], valueObject["received_certs"], valueObject["sender_name"]);
-
- // turns out on my machine, toLocalTime convert to some weird timezone, yet the
- // systemTimeZone is correct. To avoid a strange bug with other's systems too, lets
- // be explicit
- QDateTime createdAt = QDateTime::fromSecsSinceEpoch(valueObject["created_at"].toInt(), Qt::UTC);
- QDateTime localCreatedAt = createdAt.toTimeZone(QTimeZone::systemTimeZone());
- valueObject["text"] = QString("%1%2%3").arg(valueObject["message"].toString(), sent, received);
+ valueObject["hfc_text"] = hfcString(valueObject["sent_money"], valueObject["received_money"]);
+ valueObject["transaction_text"] = transactionString(valueObject);
newHistoryArray.push_back(valueObject);
}
// now copy the rest of the json -- this is inefficient