diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2021-04-26 19:08:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 19:08:44 +0200 |
commit | 2e40ea5121065558d493cddf8a94db57f87acd3e (patch) | |
tree | bb2e04058f1b6c7efeaf20d98eeeee80f5e95e25 /lib | |
parent | fd84529d1611a8b50440e08ee2af3897f1d1fb3c (diff) | |
parent | ae85fd8602cefd1b71db8cb173ed77a873dbe223 (diff) | |
download | libquotient-2e40ea5121065558d493cddf8a94db57f87acd3e.tar.gz libquotient-2e40ea5121065558d493cddf8a94db57f87acd3e.zip |
Merge pull request #461 from quotient-im/work/force-load-user-data
Make it possible to load the user metadata
Diffstat (limited to 'lib')
-rw-r--r-- | lib/user.cpp | 19 | ||||
-rw-r--r-- | lib/user.h | 4 |
2 files changed, 16 insertions, 7 deletions
diff --git a/lib/user.cpp b/lib/user.cpp index c4c4fec8..7933c5d9 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -51,13 +51,7 @@ User::User(QString userId, Connection* connection) setObjectName(id()); if (connection->userId() == id()) { // Load profile information for local user. - auto *profileJob = connection->callApi<GetUserProfileJob>(id()); - connect(profileJob, &BaseJob::result, this, [this, profileJob] { - d->defaultName = profileJob->displayname(); - d->defaultAvatar = Avatar(QUrl(profileJob->avatarUrl())); - emit defaultNameChanged(); - emit defaultAvatarChanged(); - }); + load(); } } @@ -69,6 +63,17 @@ Connection* User::connection() const User::~User() = default; +void User::load() +{ + auto *profileJob = connection()->callApi<GetUserProfileJob>(id()); + connect(profileJob, &BaseJob::result, this, [this, profileJob] { + d->defaultName = profileJob->displayname(); + d->defaultAvatar = Avatar(QUrl(profileJob->avatarUrl())); + emit defaultNameChanged(); + emit defaultAvatarChanged(); + }); +} + QString User::id() const { return d->id; } bool User::isGuest() const @@ -130,6 +130,10 @@ public Q_SLOTS: void unmarkIgnore(); /// Check whether the user is in ignore list bool isIgnored() const; + /// Force loading displayName and avartar url. This is required in + /// some cases where the you need to use an user independent of the + /// room. + void load(); Q_SIGNALS: void defaultNameChanged(); |