diff --git a/src/friendlist.cpp b/src/friendlist.cpp index 8178d8fc6..e278e5c6e 100644 --- a/src/friendlist.cpp +++ b/src/friendlist.cpp @@ -30,8 +30,9 @@ QHash FriendList::key2id; Friend* FriendList::addFriend(uint32_t friendId, const ToxPk& friendPk) { auto friendChecker = friendList.find(friendId); - if (friendChecker != friendList.end()) + if (friendChecker != friendList.end()) { qWarning() << "addFriend: friendId already taken"; + } QString alias = Settings::getInstance().getFriendAlias(friendPk); Friend* newfriend = new Friend(friendId, friendPk, alias); @@ -44,8 +45,9 @@ Friend* FriendList::addFriend(uint32_t friendId, const ToxPk& friendPk) Friend* FriendList::findFriend(uint32_t friendId) { auto f_it = friendList.find(friendId); - if (f_it != friendList.end()) + if (f_it != friendList.end()) { return *f_it; + } return nullptr; } diff --git a/src/model/friend.cpp b/src/model/friend.cpp index d69ea954a..1c0b43fc4 100644 --- a/src/model/friend.cpp +++ b/src/model/friend.cpp @@ -19,15 +19,13 @@ #include "friend.h" -#include "src/core/core.h" #include "src/model/group.h" #include "src/grouplist.h" -#include "src/nexus.h" #include "src/persistence/profile.h" #include "src/widget/form/chatform.h" -Friend::Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlias) - : userName{Core::getInstance()->getPeerName(friendPk)} +Friend::Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlias, const QString& userName) + : userName{userName} , userAlias{userAlias} , friendPk{friendPk} , friendId{friendId} @@ -35,7 +33,7 @@ Friend::Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlia , friendStatus{Status::Offline} { if (userName.isEmpty()) { - userName = friendPk.toString(); + this->userName = friendPk.toString(); } } diff --git a/src/model/friend.h b/src/model/friend.h index 2dd36dd92..e0f7ae6ee 100644 --- a/src/model/friend.h +++ b/src/model/friend.h @@ -30,7 +30,7 @@ class Friend : public Contact { Q_OBJECT public: - Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlias); + Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlias = {}, const QString &userName = {}); Friend(const Friend& other) = delete; Friend& operator=(const Friend& other) = delete;