diff --git a/Linphone/core/call-history/CallHistoryCore.cpp b/Linphone/core/call-history/CallHistoryCore.cpp index 495ebede..8d715e81 100644 --- a/Linphone/core/call-history/CallHistoryCore.cpp +++ b/Linphone/core/call-history/CallHistoryCore.cpp @@ -99,25 +99,35 @@ void CallHistoryCore::setSelf(QSharedPointer me) { [this, remoteAddress = mRemoteAddress](const std::shared_ptr &f) { auto friendModel = Utils::makeQObject_ptr(f); auto displayName = friendModel->getFullName(); - mCoreModelConnection->invokeToCore([this, friendModel, displayName]() { - mFriendModel = friendModel; - auto me = mCoreModelConnection->mCore.mQData; // Locked from previous call. - mFriendModelConnection = QSharedPointer>( - new SafeConnection(me, mFriendModel), &QObject::deleteLater); - mFriendModelConnection->makeConnectToModel(&FriendModel::fullNameChanged, [this]() { - auto fullName = mFriendModel->getFullName(); - mCoreModelConnection->invokeToCore([this, fullName]() { - if (fullName != mDisplayName) { - mDisplayName = fullName; - emit displayNameChanged(); - } - }); - }); - if (displayName != mDisplayName) { - mDisplayName = displayName; - emit displayNameChanged(); + auto fAddress = ToolModel::interpretUrl(remoteAddress); + bool isThisFriend = false; + for (auto f : friendModel->getAddresses()) { + if (f->weakEqual(fAddress)) { + isThisFriend = true; + break; } - }); + } + if (isThisFriend) + mCoreModelConnection->invokeToCore([this, friendModel, displayName]() { + mFriendModel = friendModel; + auto me = mCoreModelConnection->mCore.mQData; // Locked from previous call. + mFriendModelConnection = QSharedPointer>( + new SafeConnection(me, mFriendModel), &QObject::deleteLater); + mFriendModelConnection->makeConnectToModel(&FriendModel::fullNameChanged, [this]() { + auto fullName = mFriendModel->getFullName(); + mCoreModelConnection->invokeToCore([this, fullName]() { + if (fullName != mDisplayName) { + mDisplayName = fullName; + emit displayNameChanged(); + } + }); + }); + if (displayName != mDisplayName) { + mDisplayName = displayName; + emit displayNameChanged(); + } + emit friendAdded(); + }); }); } } diff --git a/Linphone/core/call-history/CallHistoryCore.hpp b/Linphone/core/call-history/CallHistoryCore.hpp index f8c1c746..d3e78dee 100644 --- a/Linphone/core/call-history/CallHistoryCore.hpp +++ b/Linphone/core/call-history/CallHistoryCore.hpp @@ -68,6 +68,7 @@ public: signals: void durationChanged(QString duration); void displayNameChanged(); + void friendAdded(); // When a friend is created, this log is linked to it. void removed(); private: diff --git a/Linphone/view/Page/Main/Call/CallPage.qml b/Linphone/view/Page/Main/Call/CallPage.qml index 740b6f26..f3e5a688 100644 --- a/Linphone/view/Page/Main/Call/CallPage.qml +++ b/Linphone/view/Page/Main/Call/CallPage.qml @@ -310,6 +310,13 @@ AbstractMainPage { anchors.topMargin: 5 * DefaultStyle.dp anchors.bottomMargin: 5 * DefaultStyle.dp visible: !!modelData + Connections{ + target: modelData?.core + // Update contact with the new friend. + function onFriendAdded(){ + historyAvatar.contactObj = UtilsCpp.findFriendByAddress(modelData.core.remoteAddress) + } + } RowLayout { z: 1 anchors.fill: parent