summary refs log tree commit diff
path: root/src/ui/UserProfile.cpp
diff options
context:
space:
mode:
authorJedi18 <targetakhil@gmail.com>2021-01-29 00:09:11 +0530
committerJedi18 <targetakhil@gmail.com>2021-01-29 00:09:11 +0530
commitfa7ad4f2344c72a8754a6d7b4489082fc81bb930 (patch)
treedf382cc07db913f1ab484f00ce0701b09097f648 /src/ui/UserProfile.cpp
parentfix linting (diff)
downloadnheko-fa7ad4f2344c72a8754a6d7b4489082fc81bb930.tar.xz
Shifted fetching of global username fom timeline model to user profile
Diffstat (limited to 'src/ui/UserProfile.cpp')
-rw-r--r--src/ui/UserProfile.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp

index 28757b72..df404494 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp
@@ -8,18 +8,17 @@ #include "timeline/TimelineModel.h" #include "timeline/TimelineViewManager.h" #include <mtx/responses/common.hpp> +#include <mtx/responses.hpp> UserProfile::UserProfile(QString roomid, QString userid, TimelineViewManager *manager_, - TimelineModel *parent, - QString globalUsername) + TimelineModel *parent) : QObject(parent) , roomid_(roomid) , userid_(userid) , manager(manager_) , model(parent) - , globalUsername(globalUsername) { fetchDeviceList(this->userid_); @@ -47,6 +46,23 @@ UserProfile::UserProfile(QString roomid, } deviceList_.reset(deviceList_.deviceList_); }); + + connect(this, + &UserProfile::globalUsernameRetrieved, + this, + &UserProfile::setGlobalUsername, + Qt::QueuedConnection); + + http::client()->get_profile( + userid_.toStdString(), + [this](const mtx::responses::Profile &res, mtx::http::RequestErr err) { + if (err) { + nhlog::net()->warn("failed to retrieve own profile info"); + return; + } + + emit globalUsernameRetrieved(QString::fromStdString(res.display_name)); + }); } QHash<int, QByteArray> @@ -286,3 +302,10 @@ UserProfile::isUsernameEditingAllowed() const { return usernameEditing; } + +void +UserProfile::setGlobalUsername(const QString& globalUser) +{ + globalUsername = globalUser; + emit displayNameChanged(); +} \ No newline at end of file