diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp
index 942a4b05..88411236 100644
--- a/src/timeline/RoomlistModel.cpp
+++ b/src/timeline/RoomlistModel.cpp
@@ -76,6 +76,8 @@ RoomlistModel::roleNames() const
{IsSpace, "isSpace"},
{Tags, "tags"},
{ParentSpaces, "parentSpaces"},
+ {RoomMemberCount, "roomMemberCount"},
+ {DirectChatAvatarMxid, "directChatAvatarMxid"},
};
}
@@ -129,6 +131,10 @@ RoomlistModel::data(const QModelIndex &index, int role) const
list.push_back(QString::fromStdString(t));
return list;
}
+ case Roles::RoomMemberCount:
+ return room->roomMemberCount();
+ case Roles::DirectChatAvatarMxid:
+ return room->directChatAvatarMxid();
default:
return {};
}
diff --git a/src/timeline/RoomlistModel.h b/src/timeline/RoomlistModel.h
index 6ac6da18..aca74ea1 100644
--- a/src/timeline/RoomlistModel.h
+++ b/src/timeline/RoomlistModel.h
@@ -65,6 +65,8 @@ public:
IsPreviewFetched,
Tags,
ParentSpaces,
+ RoomMemberCount,
+ DirectChatAvatarMxid,
};
RoomlistModel(TimelineViewManager *parent = nullptr);
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 78409e1d..4daf44f3 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -2073,3 +2073,16 @@ TimelineModel::roomMemberCount() const
{
return (int)cache::client()->memberCount(room_id_.toStdString());
}
+
+QString
+TimelineModel::directChatAvatarMxid() const
+{
+ if (roomMemberCount() < 3) {
+ QString id;
+ for (auto member : cache::getMembers(room_id_.toStdString()))
+ if (member.user_id != UserSettings::instance()->userId())
+ id = member.user_id;
+ return id;
+ } else
+ return "";
+}
diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index 417fbb7f..8c34fc1d 100644
--- a/src/timeline/TimelineModel.h
+++ b/src/timeline/TimelineModel.h
@@ -176,6 +176,8 @@ 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(
+ QString directChatAvatarMxid READ directChatAvatarMxid NOTIFY directChatAvatarMxidChanged)
Q_PROPERTY(InputBar *input READ input CONSTANT)
Q_PROPERTY(Permissions *permissions READ permissions NOTIFY permissionsChanged)
@@ -292,6 +294,7 @@ public:
bool isEncrypted() const { return isEncrypted_; }
crypto::Trust trustlevel() const;
int roomMemberCount() const;
+ QString directChatAvatarMxid() const;
std::optional<mtx::events::collections::TimelineEvents> eventById(const QString &id)
{
@@ -391,6 +394,7 @@ signals:
void roomTopicChanged();
void roomAvatarUrlChanged();
void roomMemberCountChanged();
+ void directChatAvatarMxidChanged();
void permissionsChanged();
void forwardToRoom(mtx::events::collections::TimelineEvents *e, QString roomId);
|