mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix #1536
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:
parent
936f055893
commit
8786f9525e
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user