1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
New friends must be added to the friend list before loading history, otherwise the history code won't find the friend in the friendlist, and the history will have blank names for the friend
This commit is contained in:
tux3 2015-04-26 14:40:07 +02:00
parent 936f055893
commit 8786f9525e
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
3 changed files with 16 additions and 5 deletions

View File

@ -35,11 +35,6 @@ Friend::Friend(uint32_t FriendId, const ToxID &UserId)
widget = new FriendWidget(friendId, getDisplayedName());
chatForm = new ChatForm(this);
if (Settings::getInstance().getEnableLogging())
{
chatForm->loadHistory(QDateTime::currentDateTime().addDays(-7), true);
widget->historyLoaded = true;
}
}
Friend::~Friend()
@ -48,6 +43,15 @@ Friend::~Friend()
delete widget;
}
void Friend::loadHistory()
{
if (Settings::getInstance().getEnableLogging())
{
chatForm->loadHistory(QDateTime::currentDateTime().addDays(-7), true);
widget->historyLoaded = true;
}
}
void Friend::setName(QString name)
{
userName = name;

View File

@ -33,6 +33,9 @@ public:
~Friend();
Friend& operator=(const Friend& other)=delete;
/// Loads the friend's chat history if enabled
void loadHistory();
void setName(QString name);
void setAlias(QString name);
QString getDisplayedName() const;

View File

@ -34,6 +34,10 @@ Friend* FriendList::addFriend(int friendId, const ToxID& userId)
friendList[friendId] = newfriend;
tox2id[userId.publicKey] = friendId;
// Must be done AFTER adding to the friendlist
// or we won't find the friend and history will have blank names
newfriend->loadHistory();
return newfriend;
}