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

@ -66,7 +66,6 @@ p3HistoryMgr::~p3HistoryMgr()
/***** p3HistoryMgr *****/
//void p3HistoryMgr::addMessage(bool incoming, const RsPeerId &chatPeerId, const RsPeerId &msgPeerId, const RsChatMsgItem *chatItem)
void p3HistoryMgr::addMessage(const ChatMessage& cm)
{
uint32_t addMsgId = 0;
@ -99,7 +98,8 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
}
if (cm.chat_id.isLobbyId() && mLobbyEnable == true) {
peerName = cm.lobby_peer_gxs_id.toStdString();
enabled = true;
msgPeerId = RsPeerId(cm.lobby_peer_gxs_id);
enabled = true;
}
if(cm.chat_id.isDistantChatId()&& mDistantEnable == true)
@ -114,6 +114,8 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
peerName = det.mNickname;
else
peerName = writer_id.toStdString();
msgPeerId = cm.incoming?RsPeerId(dcpinfo.own_id):RsPeerId(dcpinfo.to_id);
}
else
{

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);
}
}
}