From e56a966de155f02b4ddcb2a60aac65ec415956c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Mon, 27 May 2024 14:21:03 -0400 Subject: [PATCH] contactmodel: fix account avatar on link device We do not need to write an empty profile since the daemon fully manages the profile. Just update it from cache when new profile is detected GitLab: #1627 Change-Id: I31035f0666925d13f339f387e614f148b0eece8b --- src/libclient/accountmodel.cpp | 34 ------------------------------ src/libclient/callbackshandler.cpp | 15 ------------- src/libclient/callbackshandler.h | 10 --------- src/libclient/contactmodel.cpp | 9 ++++++++ 4 files changed, 9 insertions(+), 59 deletions(-) diff --git a/src/libclient/accountmodel.cpp b/src/libclient/accountmodel.cpp index 955650c4f..ac8229b55 100644 --- a/src/libclient/accountmodel.cpp +++ b/src/libclient/accountmodel.cpp @@ -166,17 +166,6 @@ public Q_SLOTS: * @param ok */ void slotMigrationEnded(const QString& accountId, bool ok); - - /** - * Emit accountProfileReceived - * @param accountId - * @param displayName - * @param userPhoto - */ - void slotAccountProfileReceived(const QString& accountId, - const QString& displayName, - const QString& userPhoto); - /** * Emit new position * @param accountId @@ -415,10 +404,6 @@ AccountModelPimpl::AccountModelPimpl(AccountModel& linked, &CallbacksHandler::migrationEnded, this, &AccountModelPimpl::slotMigrationEnded); - connect(&callbacksHandler, - &CallbacksHandler::accountProfileReceived, - this, - &AccountModelPimpl::slotAccountProfileReceived); connect(&callbacksHandler, &CallbacksHandler::newPosition, this, @@ -691,25 +676,6 @@ AccountModelPimpl::slotMigrationEnded(const QString& accountId, bool ok) Q_EMIT linked.migrationEnded(accountId, ok); } -void -AccountModelPimpl::slotAccountProfileReceived(const QString& accountId, - const QString& displayName, - const QString& userPhoto) -{ - LC_WARN << accountId << displayName; - - auto account = accounts.find(accountId); - if (account == accounts.end()) - return; - auto& accountInfo = account->second.first; - accountInfo.profileInfo.avatar = userPhoto; - accountInfo.profileInfo.alias = displayName; - - storage::vcard::setProfile(accountInfo.id, accountInfo.profileInfo); - - Q_EMIT linked.profileUpdated(accountId); -} - void AccountModelPimpl::slotNewPosition(const QString& accountId, const QString& peerId, diff --git a/src/libclient/callbackshandler.cpp b/src/libclient/callbackshandler.cpp index 51acb43c8..d1b16c294 100644 --- a/src/libclient/callbackshandler.cpp +++ b/src/libclient/callbackshandler.cpp @@ -236,13 +236,6 @@ CallbacksHandler::CallbacksHandler(const Lrc& parent) this, &CallbacksHandler::slotDeviceRevokationEnded, Qt::QueuedConnection); - - connect(&ConfigurationManager::instance(), - &ConfigurationManagerInterface::accountProfileReceived, - this, - &CallbacksHandler::slotAccountProfileReceived, - Qt::QueuedConnection); - connect(&ConfigurationManager::instance(), &ConfigurationManagerInterface::exportOnRingEnded, this, @@ -671,14 +664,6 @@ CallbacksHandler::slotDeviceRevokationEnded(const QString& accountId, Q_EMIT deviceRevocationEnded(accountId, deviceId, status); } -void -CallbacksHandler::slotAccountProfileReceived(const QString& accountId, - const QString& displayName, - const QString& userPhoto) -{ - Q_EMIT accountProfileReceived(accountId, displayName, userPhoto); -} - void CallbacksHandler::slotExportOnRingEnded(const QString& accountId, int status, const QString& pin) { diff --git a/src/libclient/callbackshandler.h b/src/libclient/callbackshandler.h index d96c13936..bef4114e0 100644 --- a/src/libclient/callbackshandler.h +++ b/src/libclient/callbackshandler.h @@ -562,16 +562,6 @@ private Q_SLOTS: const QString& deviceId, const int status); - /** - * Emit account avatar has been received - * @param accountId - * @param displayName - * @param userPhoto - */ - void slotAccountProfileReceived(const QString& accountId, - const QString& displayName, - const QString& userPhoto); - /** * Emit exportOnRingEnded * @param accountId diff --git a/src/libclient/contactmodel.cpp b/src/libclient/contactmodel.cpp index 5655b6c10..05dd5ee65 100644 --- a/src/libclient/contactmodel.cpp +++ b/src/libclient/contactmodel.cpp @@ -1175,6 +1175,15 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId, if (accountId != linked.owner.id) return; + if (linked.owner.profileInfo.uri == peer) { + const auto newProfileInfo = storage::getProfileData(accountId, ""); + linked.owner.accountModel->setAlias(accountId, newProfileInfo["alias"], false); + linked.owner.accountModel->setAvatar(accountId, newProfileInfo["avatar"], false); + + Q_EMIT linked.owner.accountModel->profileUpdated(accountId); + return; + } + // Make sure this is for a contact and not the linked account, // then just remove the URI from the cache list and notify. std::lock_guard<std::mutex> lk(contactsMtx_); -- GitLab