update sendTab
This commit is contained in:
@@ -144,8 +144,6 @@ void Controller::getInfoThenRefresh(bool force) {
|
||||
static bool prevCallSucceeded = false;
|
||||
|
||||
zrpc->fetchInfo([=] (const json& reply) {
|
||||
qDebug() << "Info updated";
|
||||
|
||||
prevCallSucceeded = true;
|
||||
|
||||
// Testnet?
|
||||
@@ -159,11 +157,13 @@ void Controller::getInfoThenRefresh(bool force) {
|
||||
if (!Settings::getInstance()->isTestnet())
|
||||
main->disableRecurring();
|
||||
|
||||
static int lastBlock = 0;
|
||||
int curBlock = reply["latest_block_height"].get<json::number_integer_t>();
|
||||
bool doUpdate = force || (model->getLatestBlock() != curBlock);
|
||||
model->setLatestBlock(curBlock);
|
||||
ui->blockHeight->setText(QString::number(curBlock));
|
||||
|
||||
qDebug() << "Refreshing. Full update: " << doUpdate;
|
||||
|
||||
// Connected, so display checkmark.
|
||||
auto tooltip = Settings::getInstance()->getSettings().server + "\n" + QString::fromStdString(reply.dump());
|
||||
QIcon i(":/icons/res/connected.gif");
|
||||
@@ -185,10 +185,8 @@ void Controller::getInfoThenRefresh(bool force) {
|
||||
// See if recurring payments needs anything
|
||||
Recurring::getInstance()->processPending(main);
|
||||
|
||||
if ( force || (curBlock != lastBlock) ) {
|
||||
if ( doUpdate ) {
|
||||
// Something changed, so refresh everything.
|
||||
lastBlock = curBlock;
|
||||
|
||||
refreshBalances();
|
||||
refreshAddresses(); // This calls refreshZSentTransactions() and refreshReceivedZTrans()
|
||||
refreshTransactions();
|
||||
@@ -347,6 +345,16 @@ void Controller::refreshTransactions() {
|
||||
CAmount total_amount;
|
||||
QList<TransactionItemDetail> items;
|
||||
|
||||
long confirmations;
|
||||
if (it.find("unconfirmed") != it.end() && it["unconfirmed"].get<json::boolean_t>()) {
|
||||
confirmations = 0;
|
||||
} else {
|
||||
confirmations = model->getLatestBlock() - it["block_height"].get<json::number_integer_t>() + 1;
|
||||
}
|
||||
|
||||
auto txid = QString::fromStdString(it["txid"]);
|
||||
auto datetime = it["datetime"].get<json::number_integer_t>();
|
||||
|
||||
// First, check if there's outgoing metadata
|
||||
if (!it["outgoing_metadata"].is_null()) {
|
||||
|
||||
@@ -375,12 +383,7 @@ void Controller::refreshTransactions() {
|
||||
}
|
||||
|
||||
txdata.push_back(TransactionItem{
|
||||
"Sent",
|
||||
it["datetime"].get<json::number_integer_t>(),
|
||||
address,
|
||||
QString::fromStdString(it["txid"]),
|
||||
model->getLatestBlock() - it["block_height"].get<json::number_integer_t>(),
|
||||
items
|
||||
"Sent", datetime, address, txid,confirmations, items
|
||||
});
|
||||
} else {
|
||||
// Incoming Transaction
|
||||
@@ -400,12 +403,7 @@ void Controller::refreshTransactions() {
|
||||
|
||||
|
||||
TransactionItem tx{
|
||||
"Receive",
|
||||
it["datetime"].get<json::number_integer_t>(),
|
||||
address,
|
||||
QString::fromStdString(it["txid"]),
|
||||
model->getLatestBlock() - it["block_height"].get<json::number_integer_t>() + 1,
|
||||
items
|
||||
"Receive", datetime, address, txid,confirmations, items
|
||||
};
|
||||
|
||||
txdata.push_back(tx);
|
||||
|
||||
Reference in New Issue
Block a user