Find users by Id in UserListModel as there may be users with the same display name which will end up with the wrong member replaced
This commit is contained in:
committed by
Tobias Fella
parent
832e6b9de0
commit
b78a9f2a9c
@@ -158,7 +158,7 @@ void UserListModel::refreshAllMembers()
|
|||||||
m_members.clear();
|
m_members.clear();
|
||||||
|
|
||||||
if (m_currentRoom != nullptr) {
|
if (m_currentRoom != nullptr) {
|
||||||
m_members = m_currentRoom->members();
|
m_members = m_currentRoom->joinedMembers();
|
||||||
std::sort(m_members.begin(), m_members.end(), m_currentRoom->memberSorter());
|
std::sort(m_members.begin(), m_members.end(), m_currentRoom->memberSorter());
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
@@ -167,15 +167,18 @@ void UserListModel::refreshAllMembers()
|
|||||||
|
|
||||||
int UserListModel::findUserPos(const RoomMember &member) const
|
int UserListModel::findUserPos(const RoomMember &member) const
|
||||||
{
|
{
|
||||||
return findUserPos(member.displayName());
|
return findUserPos(member.id());
|
||||||
}
|
}
|
||||||
|
|
||||||
int UserListModel::findUserPos(const QString &username) const
|
int UserListModel::findUserPos(const QString &userId) const
|
||||||
{
|
{
|
||||||
if (!m_currentRoom) {
|
if (!m_currentRoom) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_currentRoom->memberSorter().lowerBoundIndex(m_members, username);
|
const auto pos = std::find_if(m_members.cbegin(), m_members.cend(), [&userId](const RoomMember &member) {
|
||||||
|
return userId == member.id();
|
||||||
|
});
|
||||||
|
return pos - m_members.cbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> UserListModel::roleNames() const
|
QHash<int, QByteArray> UserListModel::roleNames() const
|
||||||
|
|||||||
Reference in New Issue
Block a user