fixed bug in chat history causing lots of gibberish output to the console

This commit is contained in:
csoler 2021-01-14 22:35:08 +01:00
parent 1bbde46c4a
commit dca8a5a91d
2 changed files with 12 additions and 17 deletions

View file

@ -406,25 +406,18 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title)
{
RsIdentityDetails details;
time_t start = time(nullptr);
while (!rsIdentity->getIdDetails(RsGxsId(historyIt->peerName), details))
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
if (time(nullptr)>start+2)
{
std::cerr << "ChatWidget History haven't found Id Details and have wait 1 sec for it." << std::endl;
break;
}
}
if (rsIdentity->getIdDetails(RsGxsId(historyIt->peerName), details))
if (rsIdentity->getIdDetails(RsGxsId(historyIt->peerId), details))
name = QString::fromUtf8(details.mNickname.c_str());
else
name = QString::fromUtf8(historyIt->peerName.c_str());
} else {
name = QString::fromUtf8(historyIt->peerName.c_str());
else if(!historyIt->peerName.empty())
name = QString::fromUtf8(historyIt->peerName.c_str());
else
name = QString::fromUtf8(historyIt->peerId.toStdString().c_str());
} else {
name = QString::fromUtf8(historyIt->peerId.toStdString().c_str());
}
addChatMsg(historyIt->incoming, name, RsGxsId(historyIt->peerName.c_str()), QDateTime::fromTime_t(historyIt->sendTime), QDateTime::fromTime_t(historyIt->recvTime), QString::fromUtf8(historyIt->message.c_str()), MSGTYPE_HISTORY);
addChatMsg(historyIt->incoming, name, RsGxsId(historyIt->peerId.toStdString().c_str()), QDateTime::fromTime_t(historyIt->sendTime), QDateTime::fromTime_t(historyIt->recvTime), QString::fromUtf8(historyIt->message.c_str()), MSGTYPE_HISTORY);
}
}
}