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