mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fix ChatWidget History UserName
Wait some time (maxi 2sec) that Id cache is loaded.
This commit is contained in:
parent
06840b86f5
commit
422f56b31a
@ -379,31 +379,42 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title)
|
|||||||
|
|
||||||
if (messageCount > 0)
|
if (messageCount > 0)
|
||||||
{
|
{
|
||||||
rsHistory->getMessages(chatId, historyMsgs, messageCount);
|
rsHistory->getMessages(chatId, historyMsgs, messageCount);
|
||||||
|
|
||||||
std::list<HistoryMsg>::iterator historyIt;
|
std::list<HistoryMsg>::iterator historyIt;
|
||||||
for (historyIt = historyMsgs.begin(); historyIt != historyMsgs.end(); ++historyIt)
|
for (historyIt = historyMsgs.begin(); historyIt != historyMsgs.end(); ++historyIt)
|
||||||
{
|
{
|
||||||
// it can happen that a message is first added to the message history
|
// it can happen that a message is first added to the message history
|
||||||
// and later the gui receives the message through notify
|
// and later the gui receives the message through notify
|
||||||
// avoid this by not adding history entries if their age is < 2secs
|
// 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;
|
continue;
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
if (chatId.isLobbyId() || chatId.isDistantChatId())
|
if (chatId.isLobbyId() || chatId.isDistantChatId())
|
||||||
{
|
{
|
||||||
RsIdentityDetails details;
|
RsIdentityDetails details;
|
||||||
if (rsIdentity->getIdDetails(RsGxsId(historyIt->peerName), details))
|
time_t start = time(nullptr);
|
||||||
name = QString::fromUtf8(details.mNickname.c_str());
|
while (!rsIdentity->getIdDetails(RsGxsId(historyIt->peerName), details))
|
||||||
else
|
{
|
||||||
name = QString::fromUtf8(historyIt->peerName.c_str());
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
} else {
|
if (time(nullptr)>start+2)
|
||||||
name = QString::fromUtf8(historyIt->peerName.c_str());
|
{
|
||||||
}
|
std::cerr << "ChatWidget History haven't found Id Details and have wait 1 sec for it." << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
if (rsIdentity->getIdDetails(RsGxsId(historyIt->peerName), details))
|
||||||
}
|
name = QString::fromUtf8(details.mNickname.c_str());
|
||||||
|
else
|
||||||
|
name = QString::fromUtf8(historyIt->peerName.c_str());
|
||||||
|
} else {
|
||||||
|
name = QString::fromUtf8(historyIt->peerName.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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user