diff options
author | arawaaa <77910862+arawaaa@users.noreply.github.com> | 2021-05-25 13:11:53 -0500 |
---|---|---|
committer | arawaaa <77910862+arawaaa@users.noreply.github.com> | 2021-05-25 13:11:53 -0500 |
commit | 28823df2af5a4bfbab6dc455252c8ea0e211ffcb (patch) | |
tree | 1c1afb8fde16c15b8b4c110f635fed88c426ec4c /lib | |
parent | 5155f825bb71fca649a97ac4a7fa356cf85ee722 (diff) | |
parent | 7761c2b791291adee0505c869305b5675e90ed3b (diff) | |
download | libquotient-28823df2af5a4bfbab6dc455252c8ea0e211ffcb.tar.gz libquotient-28823df2af5a4bfbab6dc455252c8ea0e211ffcb.zip |
Merge branch 'quotient-im:master' into pinned
Diffstat (limited to 'lib')
-rw-r--r-- | lib/connection.cpp | 8 | ||||
-rw-r--r-- | lib/user.cpp | 19 | ||||
-rw-r--r-- | lib/user.h | 4 |
3 files changed, 21 insertions, 10 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index 579c7920..a384783c 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -807,7 +807,7 @@ JoinRoomJob* Connection::joinRoom(const QString& roomAlias, // that may add their own slots to finished(). connect(job, &BaseJob::finished, this, [this, job] { if (job->status().good()) - provideRoom(job->roomId()); + provideRoom(job->roomId(), JoinState::Join); }); return job; } @@ -1464,11 +1464,13 @@ Room* Connection::provideRoom(const QString& id, Omittable<JoinState> joinState) room = d->roomMap.value({ id, true }, nullptr); if (room) return room; - // No Invite either, setup a new room object below + // No Invite either, setup a new room object in Join state + joinState = JoinState::Join; } if (!room) { - room = roomFactory()(this, id, joinState.value_or(JoinState::Join)); + Q_ASSERT(joinState.has_value()); + room = roomFactory()(this, id, *joinState); if (!room) { qCCritical(MAIN) << "Failed to create a room" << id; return nullptr; 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(); |