From c123bada94bfd21121d6d847c472c910b88fed65 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sun, 21 Jan 2018 20:28:38 +0200 Subject: Refactor avatar fetching in one function --- src/ChatPage.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/ChatPage.cc') diff --git a/src/ChatPage.cc b/src/ChatPage.cc index 71552bcf..596f72dc 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -349,7 +349,6 @@ ChatPage::ChatPage(QSharedPointer client, } }); - connect(client_.data(), &MatrixClient::ownAvatarRetrieved, this, &ChatPage::setOwnAvatar); connect(client_.data(), &MatrixClient::joinedRoom, this, [=](const QString &room_id) { emit showNotification("You joined the room."); removeInvite(room_id); @@ -493,12 +492,6 @@ ChatPage::bootstrap(QString userid, QString homeserver, QString token) client_->initialSync(); } -void -ChatPage::setOwnAvatar(const QPixmap &img) -{ - user_info_widget_->setAvatar(img.toImage()); -} - void ChatPage::syncCompleted(const mtx::responses::Sync &response) { @@ -597,7 +590,10 @@ ChatPage::updateOwnProfileInfo(const QUrl &avatar_url, const QString &display_na user_info_widget_->setDisplayName(display_name); if (avatar_url.isValid()) - client_->fetchOwnAvatar(avatar_url); + client_->fetchUserAvatar( + avatar_url, + [=](QImage img) { user_info_widget_->setAvatar(img); }, + [=](QString error) { qWarning() << error << ": failed to fetch own avatar"; }); } void -- cgit 1.5.1