Merge pull request #1630 from PhenomRetroShare/Fix_ChatWidgetHistoryUserName

Fix ChatWidget History UserName
This commit is contained in:
csoler 2020-01-18 13:57:23 +01:00 committed by GitHub
commit 6001517718
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -390,13 +390,24 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title)
// it can happen that a message is first added to the message history
// and later the gui receives the message through notify
// avoid this by not adding history entries if their age is < 2secs
if ((time(NULL)-2) <= historyIt->recvTime)
if (time(nullptr) <= historyIt->recvTime+2)
continue;
QString name;
if (chatId.isLobbyId() || chatId.isDistantChatId())
{
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))
name = QString::fromUtf8(details.mNickname.c_str());
else