add user search to invite dialog (#1253)
This commit is contained in:
parent
3abb49c4a2
commit
5ed3bfc8f8
12 changed files with 437 additions and 99 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <QUrl>
|
||||
|
||||
#include "Cache.h"
|
||||
#include "Cache_p.h"
|
||||
#include "CompletionModelRoles.h"
|
||||
#include "UserSettingsPage.h"
|
||||
|
||||
|
|
@ -16,10 +17,29 @@ UsersModel::UsersModel(const std::string &roomId, QObject *parent)
|
|||
: QAbstractListModel(parent)
|
||||
, room_id(roomId)
|
||||
{
|
||||
roomMembers_ = cache::roomMembers(roomId);
|
||||
for (const auto &m : roomMembers_) {
|
||||
displayNames.push_back(QString::fromStdString(cache::displayName(room_id, m)));
|
||||
userids.push_back(QString::fromStdString(m));
|
||||
// obviously, "friends" isn't a room, but I felt this was the least invasive way
|
||||
if (roomId == "friends") {
|
||||
auto e = cache::client()->getAccountData(mtx::events::EventType::Direct);
|
||||
if (e) {
|
||||
if (auto event =
|
||||
std::get_if<mtx::events::AccountDataEvent<mtx::events::account_data::Direct>>(
|
||||
&e.value())) {
|
||||
for (const auto &[userId, roomIds] : event->content.user_to_rooms) {
|
||||
displayNames.push_back(
|
||||
QString::fromStdString(cache::displayName(roomIds[0], userId)));
|
||||
userids.push_back(QString::fromStdString(userId));
|
||||
avatarUrls.push_back(cache::avatarUrl(QString::fromStdString(roomIds[0]),
|
||||
QString::fromStdString(userId)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const auto &m : cache::roomMembers(roomId)) {
|
||||
displayNames.push_back(QString::fromStdString(cache::displayName(room_id, m)));
|
||||
userids.push_back(QString::fromStdString(m));
|
||||
avatarUrls.push_back(
|
||||
cache::avatarUrl(QString::fromStdString(room_id), QString::fromStdString(m)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -59,8 +79,7 @@ UsersModel::data(const QModelIndex &index, int role) const
|
|||
case CompletionModel::SearchRole2:
|
||||
return userids[index.row()];
|
||||
case Roles::AvatarUrl:
|
||||
return cache::avatarUrl(QString::fromStdString(room_id),
|
||||
QString::fromStdString(roomMembers_[index.row()]));
|
||||
return avatarUrls[index.row()];
|
||||
case Roles::UserID:
|
||||
return userids[index.row()].toHtmlEscaped();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue