Make use of new RoomMember item from libquotient
Depends on https://github.com/quotient-im/libQuotient/pull/695 Currently basic just to show a working implementation using RoomMember. Currently only the room event and search models are moved over. Will change everything else over once the dependent pr is complete.
This commit is contained in:
committed by
Tobias Fella
parent
58d727350d
commit
430bafafe7
@@ -7,45 +7,6 @@
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
using namespace Quotient;
|
||||
|
||||
static const QVariantMap emptyUser = {
|
||||
{"isLocalUser"_ls, false},
|
||||
{"id"_ls, QString()},
|
||||
{"displayName"_ls, QString()},
|
||||
{"avatarSource"_ls, QUrl()},
|
||||
{"avatarMediaId"_ls, QString()},
|
||||
{"color"_ls, QColor()},
|
||||
{"object"_ls, QVariant()},
|
||||
};
|
||||
|
||||
QVariantMap QmlUtils::getUser(User *user) const
|
||||
{
|
||||
if (user == nullptr) {
|
||||
return emptyUser;
|
||||
}
|
||||
|
||||
const auto &url = user->avatarUrl();
|
||||
if (url.isEmpty() || url.scheme() != "mxc"_ls) {
|
||||
return {};
|
||||
}
|
||||
auto avatarSource = user->connection()->makeMediaUrl(url);
|
||||
if (!avatarSource.isValid() || avatarSource.scheme() != QStringLiteral("mxc")) {
|
||||
avatarSource = {};
|
||||
}
|
||||
|
||||
return QVariantMap{
|
||||
{QStringLiteral("isLocalUser"), user->id() == user->connection()->user()->id()},
|
||||
{QStringLiteral("id"), user->id()},
|
||||
{QStringLiteral("displayName"), user->displayname()},
|
||||
{QStringLiteral("escapedDisplayName"), user->displayname().toHtmlEscaped()},
|
||||
{QStringLiteral("avatarSource"), avatarSource},
|
||||
{QStringLiteral("avatarMediaId"), user->avatarMediaId()},
|
||||
{QStringLiteral("color"), Utils::getUserColor(user->hueF())},
|
||||
{QStringLiteral("object"), QVariant::fromValue(user)},
|
||||
};
|
||||
}
|
||||
|
||||
bool QmlUtils::isValidJson(const QByteArray &json)
|
||||
{
|
||||
return !QJsonDocument::fromJson(json).isNull();
|
||||
|
||||
Reference in New Issue
Block a user