diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-01-21 20:28:38 +0200 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-01-21 20:28:38 +0200 |
commit | c123bada94bfd21121d6d847c472c910b88fed65 (patch) | |
tree | beb24ae17228126b91468cd683d78a8f0910ab0f /src/ChatPage.cc | |
parent | Fix iterator crash (diff) | |
download | nheko-c123bada94bfd21121d6d847c472c910b88fed65.tar.xz |
Refactor avatar fetching in one function
Diffstat (limited to 'src/ChatPage.cc')
-rw-r--r-- | src/ChatPage.cc | 12 |
1 files changed, 4 insertions, 8 deletions
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<MatrixClient> 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); @@ -494,12 +493,6 @@ ChatPage::bootstrap(QString userid, QString homeserver, QString token) } void -ChatPage::setOwnAvatar(const QPixmap &img) -{ - user_info_widget_->setAvatar(img.toImage()); -} - -void ChatPage::syncCompleted(const mtx::responses::Sync &response) { syncTimeoutTimer_->stop(); @@ -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 |