Fix autocompletion

Now it will save a map from display name to id and use that to generate
clean matrix.to links. This also make sure the colors used for the
preview are correct by using NeoChatUser and fix the bug with the regex
by simply removing the regex.

Fix #234
This commit is contained in:
Carl Schwan
2021-01-11 02:18:00 +01:00
parent ed26e87c96
commit a3e1e1d0a4
4 changed files with 31 additions and 6 deletions

View File

@@ -266,7 +266,15 @@ QVariantList NeoChatRoom::getUsers(const QString &keyword) const
QVariantList matchedList;
for (const auto u : userList) {
if (u->displayname(this).contains(keyword, Qt::CaseInsensitive)) {
matchedList.append(QVariant::fromValue(u));
NeoChatUser user(u->id(), u->connection());
QVariantMap userVariant {
{ QStringLiteral("id"), user.id() },
{ QStringLiteral("displayName"), user.displayname(this) },
{ QStringLiteral("avatarMediaId"), user.avatarMediaId(this) },
{ QStringLiteral("color"), user.color() }
};
matchedList.append(QVariant::fromValue(userVariant));
}
}