aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2021-01-21 21:30:31 +0100
committerCarl Schwan <carl@carlschwan.eu>2021-01-23 16:34:51 +0100
commit3a23e40be271a54db84c39c1ba47956915bb23ec (patch)
tree45ca895ea62ac5d25c6095751974cdadaffc2b50 /lib
parentced197fc6606c0f12eee161408742da54f40411b (diff)
downloadlibquotient-3a23e40be271a54db84c39c1ba47956915bb23ec.tar.gz
libquotient-3a23e40be271a54db84c39c1ba47956915bb23ec.zip
Load user info (display name + avatar) for the local user.
This is needed for a few cases like the account list in NeoChat or the account switcher. In this cases we don't have a room binded to the user and can't fetch the real display name and avatar.
Diffstat (limited to 'lib')
-rw-r--r--lib/user.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/user.cpp b/lib/user.cpp
index bed7be3a..9f0386f4 100644
--- a/lib/user.cpp
+++ b/lib/user.cpp
@@ -49,6 +49,16 @@ User::User(QString userId, Connection* connection)
: QObject(connection), d(new Private(move(userId)))
{
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();
+ });
+ }
}
Connection* User::connection() const