From 3a23e40be271a54db84c39c1ba47956915bb23ec Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 21 Jan 2021 21:30:31 +0100 Subject: 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. --- lib/user.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/user.cpp') 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(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 -- cgit v1.2.3