aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-02-16 10:13:19 +0100
committerGitHub <noreply@github.com>2021-02-16 10:13:19 +0100
commit48d2ecc4df4d1883326036e55949156cfb37acc6 (patch)
tree0daf4b37c887cb3292c4713c611e144d2a8bb5c1
parent3fbd9ca775caeca4a28aeb48f5c8db013659c263 (diff)
parentfb6e3f215774d48f7e0c6000cc7a9ebbc66ceb64 (diff)
downloadlibquotient-48d2ecc4df4d1883326036e55949156cfb37acc6.tar.gz
libquotient-48d2ecc4df4d1883326036e55949156cfb37acc6.zip
Merge pull request #442 from ognarb/localuserinfo
Load user info (display name + avatar) for the local user.
-rw-r--r--lib/user.cpp10
-rw-r--r--quotest/quotest.cpp8
2 files changed, 18 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
diff --git a/quotest/quotest.cpp b/quotest/quotest.cpp
index 5098bc02..bf29c434 100644
--- a/quotest/quotest.cpp
+++ b/quotest/quotest.cpp
@@ -101,6 +101,7 @@ private slots:
TEST_DECL(setTopic)
TEST_DECL(changeName)
TEST_DECL(sendAndRedact)
+ TEST_DECL(showLocalUsername)
TEST_DECL(addAndRemoveTag)
TEST_DECL(markDirectChat)
TEST_DECL(visitResources)
@@ -508,6 +509,13 @@ TEST_IMPL(changeName)
return false;
}
+
+TEST_IMPL(showLocalUsername)
+{
+ auto* const localUser = connection()->user();
+ FINISH_TEST(!localUser->name().contains("@"));
+}
+
TEST_IMPL(sendAndRedact)
{
clog << "Sending a message to redact" << endl;