mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
Use better id loading methodology
This commit is contained in:
parent
1ac4f3a97b
commit
350fc593ed
7 changed files with 20 additions and 8 deletions
|
@ -12,6 +12,7 @@ Rectangle {
|
||||||
|
|
||||||
property string url
|
property string url
|
||||||
property string userid
|
property string userid
|
||||||
|
property string roomid
|
||||||
property string displayName
|
property string displayName
|
||||||
property alias textColor: label.color
|
property alias textColor: label.color
|
||||||
property bool crop: true
|
property bool crop: true
|
||||||
|
@ -43,7 +44,7 @@ Rectangle {
|
||||||
id: identicon
|
id: identicon
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: img.status != Image.Ready && Settings.useIdenticon
|
visible: img.status != Image.Ready && Settings.useIdenticon
|
||||||
source: Settings.useIdenticon ? "image://jdenticon/" + userid + "?radius=" + radius : ""
|
source: Settings.useIdenticon ? ("image://jdenticon/" + (userid !== "" ? userid : roomid) + "?radius=" + (Settings.avatarCircles ? 100 : 25) + ((avatar.crop) ? "" : "&scale")) : ""
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|
|
@ -143,7 +143,7 @@ Page {
|
||||||
required property int notificationCount
|
required property int notificationCount
|
||||||
required property bool hasLoudNotification
|
required property bool hasLoudNotification
|
||||||
required property bool hasUnreadMessages
|
required property bool hasUnreadMessages
|
||||||
required property int roomMemberCount
|
required property bool isDirect
|
||||||
required property string directChatAvatarMxid
|
required property string directChatAvatarMxid
|
||||||
|
|
||||||
color: background
|
color: background
|
||||||
|
@ -239,7 +239,8 @@ Page {
|
||||||
width: avatarSize
|
width: avatarSize
|
||||||
url: avatarUrl.replace("mxc://", "image://MxcImage/")
|
url: avatarUrl.replace("mxc://", "image://MxcImage/")
|
||||||
displayName: roomName
|
displayName: roomName
|
||||||
userid: roomMemberCount < 3 ? directChatAvatarMxid : roomId
|
userid: isDirect ? directChatAvatarMxid : undefined
|
||||||
|
roomid: roomId
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: collapsedNotificationBubble
|
id: collapsedNotificationBubble
|
||||||
|
|
|
@ -65,7 +65,8 @@ Rectangle {
|
||||||
width: Nheko.avatarSize
|
width: Nheko.avatarSize
|
||||||
height: Nheko.avatarSize
|
height: Nheko.avatarSize
|
||||||
url: avatarUrl.replace("mxc://", "image://MxcImage/")
|
url: avatarUrl.replace("mxc://", "image://MxcImage/")
|
||||||
userid: room.roomMemberCount < 3 ? room.directChatAvatarMxid : room.roomId
|
roomid: room.roomId
|
||||||
|
userid: room.isDirect ? room.directChatAvatarMxid : undefined
|
||||||
displayName: roomName
|
displayName: roomName
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (room)
|
if (room)
|
||||||
|
|
|
@ -76,7 +76,7 @@ RoomlistModel::roleNames() const
|
||||||
{IsSpace, "isSpace"},
|
{IsSpace, "isSpace"},
|
||||||
{Tags, "tags"},
|
{Tags, "tags"},
|
||||||
{ParentSpaces, "parentSpaces"},
|
{ParentSpaces, "parentSpaces"},
|
||||||
{RoomMemberCount, "roomMemberCount"},
|
{IsDirect, "isDirect"},
|
||||||
{DirectChatAvatarMxid, "directChatAvatarMxid"},
|
{DirectChatAvatarMxid, "directChatAvatarMxid"},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -131,8 +131,8 @@ RoomlistModel::data(const QModelIndex &index, int role) const
|
||||||
list.push_back(QString::fromStdString(t));
|
list.push_back(QString::fromStdString(t));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
case Roles::RoomMemberCount:
|
case Roles::IsDirect:
|
||||||
return room->roomMemberCount();
|
return room->isDirect();
|
||||||
case Roles::DirectChatAvatarMxid:
|
case Roles::DirectChatAvatarMxid:
|
||||||
return room->directChatAvatarMxid();
|
return room->directChatAvatarMxid();
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -65,7 +65,7 @@ public:
|
||||||
IsPreviewFetched,
|
IsPreviewFetched,
|
||||||
Tags,
|
Tags,
|
||||||
ParentSpaces,
|
ParentSpaces,
|
||||||
RoomMemberCount,
|
IsDirect,
|
||||||
DirectChatAvatarMxid,
|
DirectChatAvatarMxid,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -817,6 +817,12 @@ TimelineModel::syncState(const mtx::responses::State &s)
|
||||||
emit roomAvatarUrlChanged();
|
emit roomAvatarUrlChanged();
|
||||||
emit roomNameChanged();
|
emit roomNameChanged();
|
||||||
emit roomMemberCountChanged();
|
emit roomMemberCountChanged();
|
||||||
|
|
||||||
|
if (roomMemberCount() <= 2)
|
||||||
|
{
|
||||||
|
emit isDirectChanged();
|
||||||
|
emit directChatAvatarMxidChanged();
|
||||||
|
}
|
||||||
} else if (std::holds_alternative<StateEvent<state::Encryption>>(e)) {
|
} else if (std::holds_alternative<StateEvent<state::Encryption>>(e)) {
|
||||||
this->isEncrypted_ = cache::isRoomEncrypted(room_id_.toStdString());
|
this->isEncrypted_ = cache::isRoomEncrypted(room_id_.toStdString());
|
||||||
emit encryptionChanged();
|
emit encryptionChanged();
|
||||||
|
|
|
@ -176,6 +176,7 @@ class TimelineModel : public QAbstractListModel
|
||||||
Q_PROPERTY(bool isEncrypted READ isEncrypted NOTIFY encryptionChanged)
|
Q_PROPERTY(bool isEncrypted READ isEncrypted NOTIFY encryptionChanged)
|
||||||
Q_PROPERTY(bool isSpace READ isSpace CONSTANT)
|
Q_PROPERTY(bool isSpace READ isSpace CONSTANT)
|
||||||
Q_PROPERTY(int trustlevel READ trustlevel NOTIFY trustlevelChanged)
|
Q_PROPERTY(int trustlevel READ trustlevel NOTIFY trustlevelChanged)
|
||||||
|
Q_PROPERTY(bool isDirect READ isDirect NOTIFY isDirectChanged)
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
QString directChatAvatarMxid READ directChatAvatarMxid NOTIFY directChatAvatarMxidChanged)
|
QString directChatAvatarMxid READ directChatAvatarMxid NOTIFY directChatAvatarMxidChanged)
|
||||||
Q_PROPERTY(InputBar *input READ input CONSTANT)
|
Q_PROPERTY(InputBar *input READ input CONSTANT)
|
||||||
|
@ -294,6 +295,7 @@ public:
|
||||||
bool isEncrypted() const { return isEncrypted_; }
|
bool isEncrypted() const { return isEncrypted_; }
|
||||||
crypto::Trust trustlevel() const;
|
crypto::Trust trustlevel() const;
|
||||||
int roomMemberCount() const;
|
int roomMemberCount() const;
|
||||||
|
bool isDirect() const { return roomMemberCount() <= 2; } // TODO: handle invites
|
||||||
QString directChatAvatarMxid() const;
|
QString directChatAvatarMxid() const;
|
||||||
|
|
||||||
std::optional<mtx::events::collections::TimelineEvents> eventById(const QString &id)
|
std::optional<mtx::events::collections::TimelineEvents> eventById(const QString &id)
|
||||||
|
@ -394,6 +396,7 @@ signals:
|
||||||
void roomTopicChanged();
|
void roomTopicChanged();
|
||||||
void roomAvatarUrlChanged();
|
void roomAvatarUrlChanged();
|
||||||
void roomMemberCountChanged();
|
void roomMemberCountChanged();
|
||||||
|
void isDirectChanged();
|
||||||
void directChatAvatarMxidChanged();
|
void directChatAvatarMxidChanged();
|
||||||
void permissionsChanged();
|
void permissionsChanged();
|
||||||
void forwardToRoom(mtx::events::collections::TimelineEvents *e, QString roomId);
|
void forwardToRoom(mtx::events::collections::TimelineEvents *e, QString roomId);
|
||||||
|
|
Loading…
Reference in a new issue