diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-03-12 00:15:06 +0200 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-03-12 00:15:06 +0200 |
commit | 39a8150faea00a6ba6202df3f0bc1a0bb4868646 (patch) | |
tree | c4eaed6868e79bcd88ee92dcc1cc6e08d74568c8 /src/RoomState.cc | |
parent | Add context menu option to mark events individually as read (diff) | |
download | nheko-39a8150faea00a6ba6202df3f0bc1a0bb4868646.tar.xz |
Update room name & avatar on new rooms
fixes #253
Diffstat (limited to 'src/RoomState.cc')
-rw-r--r-- | src/RoomState.cc | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/RoomState.cc b/src/RoomState.cc index 244d9e51..de816524 100644 --- a/src/RoomState.cc +++ b/src/RoomState.cc @@ -51,32 +51,41 @@ RoomState::resolveName() } QSettings settings; - auto user_id = settings.value("auth/user_id"); + auto user_id = settings.value("auth/user_id").toString(); // TODO: Display names should be sorted alphabetically. for (const auto membership : memberships) { const auto stateKey = QString::fromStdString(membership.second.state_key); - if (stateKey == user_id) + if (stateKey == user_id) { + name_ = QString::fromStdString(membership.second.content.display_name); + + if (name_.isEmpty()) + name_ = stateKey; + + userAvatar_ = stateKey; + continue; + } - if (membership.second.content.membership == mtx::events::state::Membership::Join) { + if (membership.second.content.membership == mtx::events::state::Membership::Join || + membership.second.content.membership == + mtx::events::state::Membership::Invite) { userAvatar_ = stateKey; - auto displayName = - QString::fromStdString(membership.second.content.display_name); - if (displayName.isEmpty()) + name_ = QString::fromStdString(membership.second.content.display_name); + + if (name_.isEmpty()) name_ = stateKey; - else - name_ = displayName; + // TODO: pluralization + if (memberships.size() > 2) + name_ = QString("%1 and %2 others") + .arg(name_) + .arg(memberships.size() - 2); break; } } - - // TODO: pluralization - if (memberships.size() > 2) - name_ = QString("%1 and %2 others").arg(name_).arg(memberships.size()); } void |