diff options
author | Carl Schwan <carl@carlschwan.eu> | 2021-04-26 17:52:49 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2021-04-26 17:52:49 +0200 |
commit | ae85fd8602cefd1b71db8cb173ed77a873dbe223 (patch) | |
tree | bb2e04058f1b6c7efeaf20d98eeeee80f5e95e25 /lib/user.cpp | |
parent | fd84529d1611a8b50440e08ee2af3897f1d1fb3c (diff) | |
download | libquotient-ae85fd8602cefd1b71db8cb173ed77a873dbe223.tar.gz libquotient-ae85fd8602cefd1b71db8cb173ed77a873dbe223.zip |
Make it possible to load the user metadata
In the normal case there is always a room that is associated with an
user. So it is in most of the cases, possible to load the metadata
(display name and avatar url) with the help of the room.
In some cases, it is not possible. For example, when opening an user
matrix link pointing to an user and not to a room. In this case, we need
to load the metadata independly of the room, since the user is not
linked to a room.
Diffstat (limited to 'lib/user.cpp')
-rw-r--r-- | lib/user.cpp | 19 |
1 files changed, 12 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 |