diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index e5864f8..b0acb38 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -216,6 +216,11 @@ void ChatModel::addrequestZaddr(QString tx, QString requestZaddr) this->requestZaddrMap[tx] = requestZaddr; } +void ChatModel::addconfirmations(QString tx, int confirmation) +{ + this->confirmationsMap[tx] = confirmation; +} + QString ChatModel::getCidByTx(QString tx) { for(auto& pair : this->cidMap) @@ -231,6 +236,21 @@ QString ChatModel::getCidByTx(QString tx) return QString("0xdeadbeef"); } +QString ChatModel::getConfirmationByTx(QString tx) +{ + for(auto& pair : this->confirmationsMap) + { + + } + + if(this->confirmationsMap.count(tx) > 0) + { + return this->confirmationsMap[tx]; + } + + return QString("0xdeadbeef"); +} + QString ChatModel::getrequestZaddrByTx(QString tx) { for(auto& pair : this->requestZaddrMap) @@ -256,6 +276,11 @@ void ChatModel::killrequestZaddrCache() this->requestZaddrMap.clear(); } +void ChatModel::killConfirmationCache() +{ + this->confirmationsMap.clear(); +} + QString MainWindow::createHeaderMemo(QString type, QString cid, QString zaddr, int version=0, int headerNumber=1) { diff --git a/src/chatmodel.h b/src/chatmodel.h index e8bc3e7..7ca5a0f 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -32,6 +32,7 @@ class ChatModel MainWindow* main; std::map cidMap; std::map requestZaddrMap; + std::map confirmationsMap; std::map> sendrequestMap; public: @@ -49,10 +50,13 @@ class ChatModel void addMessage(QString timestamp, ChatItem item); void addCid(QString tx, QString cid); void addrequestZaddr(QString tx, QString requestZaddr); + void addconfirmations(QString tx, int confirmation); void addSendRequest(int i, QString myAddr, QString cid, QString addr ); QString getCidByTx(QString tx); QString getrequestZaddrByTx(QString tx); + QString getConfirmationByTx(QString tx); void killCidCache(); + void killConfirmationCache(); void killrequestZaddrCache(); }; diff --git a/src/controller.cpp b/src/controller.cpp index cd6152b..541821c 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -896,6 +896,16 @@ void Controller::refreshTransactions() { CAmount amount = CAmount::fromqint64(-1* o["value"].get()); // Check for Memos + + if (confirmations == 0) { + chatModel->addconfirmations(txid, confirmations); + } + + if ((confirmations == 1) && (chatModel->getConfirmationByTx(txid) != QString("0xdeadbeef"))){ + DataStore::getChatDataStore()->clear(); + chatModel->killConfirmationCache(); + this->refresh(true); + } QString memo; if (!o["memo"].is_null()) { @@ -912,10 +922,6 @@ void Controller::refreshTransactions() { isNotarized = false; } - if (confirmations == 1) { - DataStore::getChatDataStore()->clear(); - this->refresh(true); - } qDebug()<<"Conf : " << confirmations; ChatItem item = ChatItem( @@ -932,10 +938,13 @@ void Controller::refreshTransactions() { isNotarized ); DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item); + + + } - + // this->refresh(true); items.push_back(TransactionItemDetail{address, amount, memo}); total_amount = total_amount + amount; }