Prevent chats from being showed twice, fixes qa#1
This commit is contained in:
@@ -91,6 +91,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
|
|||||||
|
|
||||||
QStandardItemModel *chat = new QStandardItemModel();
|
QStandardItemModel *chat = new QStandardItemModel();
|
||||||
DataStore::getChatDataStore()->dump(); // test to see if the chat items in datastore are correctly dumped to json
|
DataStore::getChatDataStore()->dump(); // test to see if the chat items in datastore are correctly dumped to json
|
||||||
|
std::map<QString,int> seenTxids;
|
||||||
|
|
||||||
qDebug() << __func__ << ": looking at memos...";
|
qDebug() << __func__ << ": looking at memos...";
|
||||||
for (auto &contact : AddressBook::getInstance()->getAllAddressLabels())
|
for (auto &contact : AddressBook::getInstance()->getAllAddressLabels())
|
||||||
@@ -120,11 +121,27 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
|
|||||||
QStandardItem *Items1 = new QStandardItem(memo.second.toChatLine());
|
QStandardItem *Items1 = new QStandardItem(memo.second.toChatLine());
|
||||||
Items1->setData(INCOMING, Qt::UserRole + 1);
|
Items1->setData(INCOMING, Qt::UserRole + 1);
|
||||||
qDebug() << __func__ << ": appending row to INCOMING chatitems to contact " << contact.getName() << "with txid=" << memo.second.getTxid() << " cid=" << contact.getCid() << " item " << Items1 << " memo=" << memo.second.getMemo();
|
qDebug() << __func__ << ": appending row to INCOMING chatitems to contact " << contact.getName() << "with txid=" << memo.second.getTxid() << " cid=" << contact.getCid() << " item " << Items1 << " memo=" << memo.second.getMemo();
|
||||||
chat->appendRow(Items1);
|
|
||||||
ui->listChat->setModel(chat);
|
|
||||||
ui->memoTxtChat->setEnabled(true);
|
if(seenTxids.count( memo.second.getTxid() ) > 0) {
|
||||||
ui->emojiButton->setEnabled(true);
|
// Do not render the same chat multiple times
|
||||||
ui->sendChatButton->setEnabled(true);
|
// TODO: this should also look at outputindex to allow for multi-part memos, when that is supported
|
||||||
|
qDebug() << __func__ << ": INCOMING ignoring txid=" << memo.second.getTxid();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: better header memo detection
|
||||||
|
if (memo.second.getMemo().startsWith("{")) {
|
||||||
|
qDebug() << __func__ << ": ignoring header memo=" << memo.second.getMemo();
|
||||||
|
} else {
|
||||||
|
chat->appendRow(Items1);
|
||||||
|
ui->listChat->setModel(chat);
|
||||||
|
ui->memoTxtChat->setEnabled(true);
|
||||||
|
ui->emojiButton->setEnabled(true);
|
||||||
|
ui->sendChatButton->setEnabled(true);
|
||||||
|
|
||||||
|
seenTxids[ memo.second.getTxid() ] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ui->listChat->setModel(chat);
|
ui->listChat->setModel(chat);
|
||||||
|
|||||||
@@ -1348,8 +1348,9 @@ void Controller::refreshTransactions() {
|
|||||||
isContact
|
isContact
|
||||||
);
|
);
|
||||||
|
|
||||||
qDebug() << "refreshTransactions: adding chatItem with memodecrypt=" << memodecrypt;
|
auto iid = ChatIDGenerator::getInstance()->generateID(item);
|
||||||
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
qDebug() << "refreshTransactions: adding chatItem with item id=" << iid << " memodecrypt=" << memodecrypt;
|
||||||
|
DataStore::getChatDataStore()->setData(iid, item);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << __func__ << ": ignoring txid="<< txid;
|
qDebug() << __func__ << ": ignoring txid="<< txid;
|
||||||
@@ -1373,9 +1374,9 @@ void Controller::refreshTransactions() {
|
|||||||
isNotarized,
|
isNotarized,
|
||||||
isContact
|
isContact
|
||||||
);
|
);
|
||||||
|
auto iid = ChatIDGenerator::getInstance()->generateID(item);
|
||||||
qDebug() << "refreshTransactions: adding chatItem for initial CR with memo=" << memo;
|
qDebug() << "refreshTransactions: adding chatItem for initial CR with item id="<< iid << " memo='" << memo << "'";
|
||||||
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
DataStore::getChatDataStore()->setData(iid, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user