From 8ffed6683c012ca87e14d5aa030f4ac2ca95607c Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Tue, 2 Jun 2020 20:19:18 +0200 Subject: [PATCH] dont refresh to often --- src/DataStore/ChatDataStore.cpp | 3 ++- src/chatmodel.cpp | 2 +- src/controller.cpp | 35 +++++++++++++-------------------- src/controller.h | 1 + src/mainwindow.cpp | 4 +++- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/DataStore/ChatDataStore.cpp b/src/DataStore/ChatDataStore.cpp index 7bb3840..7b03c0e 100644 --- a/src/DataStore/ChatDataStore.cpp +++ b/src/DataStore/ChatDataStore.cpp @@ -60,7 +60,8 @@ std::map ChatDataStore::getAllNewContactRequests() if ( (c.second.isOutgoing() == false) && (c.second.getType() == "Cont") && - (c.second.isContact() == false) + (c.second.isContact() == false) && + (c.second.getMemo().isEmpty()) ) { diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 8d5d32f..2358ae9 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -618,7 +618,7 @@ void MainWindow::sendChat() { } ); - rpc->refresh(true); + // rpc->refresh(true); } QString MainWindow::doSendChatTxValidations(Tx tx) { diff --git a/src/controller.cpp b/src/controller.cpp index 4c7edfe..66c00b8 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -963,22 +963,12 @@ void Controller::refreshTransactions() { }else{ publickey = ""; } - - - - int lengthcid = cid.length(); - - char *cidchar = NULL; - cidchar = new char[lengthcid+1]; - strncpy(cidchar, cid.toLocal8Bit(), lengthcid +1); /////We need to filter out Memos smaller then the ciphertext size, or it will dump if ((memo.startsWith("{") == false) && (headerbytes > 0)) { - - //QString myAddr = p.getMyAddress(); QString passphrase = main->getPassword(); QString hashEncryptionKey = passphrase; int length = hashEncryptionKey.length(); @@ -1068,11 +1058,11 @@ void Controller::refreshTransactions() { if (ui->decryptionMessage->isChecked()){ memodecrypt = QString::fromUtf8( decryptedMemo.data(), decryptedMemo.size()); DataStore::getChatDataStore()->clear(); - this->refresh(true); + // this->refresh(true); chat->renderChatBox(ui, ui->listChat,ui->memoSizeChat); }else{ memodecrypt = memo; DataStore::getChatDataStore()->clear(); - this->refresh(true); + // this->refresh(true); chat->renderChatBox(ui, ui->listChat,ui->memoSizeChat); } @@ -1097,7 +1087,7 @@ void Controller::refreshTransactions() { ); DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item); - + updateUIBalances(); }else{ @@ -1117,7 +1107,7 @@ void Controller::refreshTransactions() { false ); DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item); - + updateUIBalances(); } } @@ -1181,7 +1171,7 @@ void Controller::refreshTransactions() { chatModel->addAddressbylabel(address, requestZaddr); } else{} - + } if (chatModel->Addressbylabel(address) != QString("0xdeadbeef")){ isContact = true; @@ -1359,12 +1349,15 @@ void Controller::refreshTransactions() { if (ui->decryptionMessage->isChecked()){ memodecrypt = QString::fromUtf8( decryptedMemo.data(), decryptedMemo.size()); DataStore::getChatDataStore()->clear(); - this->refresh(true); - chat->renderChatBox(ui, ui->listChat,ui->memoSizeChat); - }else{ memodecrypt = memo; - DataStore::getChatDataStore()->clear(); - this->refresh(true); + // this->refresh(true); chat->renderChatBox(ui, ui->listChat,ui->memoSizeChat); + + }else{ + + memodecrypt = memo; + DataStore::getChatDataStore()->clear(); + //this->refresh(true); + chat->renderChatBox(ui, ui->listChat,ui->memoSizeChat); } @@ -1415,7 +1408,7 @@ void Controller::refreshTransactions() { } - } + // } } } } diff --git a/src/controller.h b/src/controller.h index 9fd445b..f66596f 100644 --- a/src/controller.h +++ b/src/controller.h @@ -80,6 +80,7 @@ public: void refreshGBPCAP(); void refreshAUDCAP(); + void refreshChat(QListView *listWidget, QLabel *label); void refreshContacts(QListView *listWidget); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bd12d90..4984811 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1357,7 +1357,9 @@ void MainWindow::setupchatTab() { ui->memoTxtChat->setTextColor("Black"); } - + + ui->decryptionMessage->setChecked(true); + QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::sendChat); QObject::connect(ui->safeContactRequest, &QPushButton::clicked, this, &MainWindow::addContact); QObject::connect(ui->pushContact, &QPushButton::clicked, this , &MainWindow::renderContactRequest);