Space notification count

Show the number of notifications for a space if it isn't selected. This respects choices like low priority only adding highlights.
This commit is contained in:
James Graham
2024-02-18 11:04:56 +00:00
parent fcf64a7e1b
commit 1b59917f16
9 changed files with 217 additions and 29 deletions

View File

@@ -298,30 +298,7 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
return room->topic();
}
if (role == CategoryRole) {
if (room->joinState() == JoinState::Invite) {
return NeoChatRoomType::Invited;
}
if (room->isFavourite()) {
return NeoChatRoomType::Favorite;
}
if (room->isLowPriority()) {
return NeoChatRoomType::Deprioritized;
}
if (room->isDirectChat()) {
return NeoChatRoomType::Direct;
}
const RoomCreateEvent *creationEvent = room->creation();
if (!creationEvent) {
return NeoChatRoomType::Normal;
}
QJsonObject contentJson = creationEvent->contentJson();
QJsonObject::const_iterator typeIter = contentJson.find("type"_ls);
if (typeIter != contentJson.end()) {
if (typeIter.value().toString() == "m.space"_ls) {
return NeoChatRoomType::Space;
}
}
return NeoChatRoomType::Normal;
return category(room);
}
if (role == NotificationCountRole) {
return room->notificationCount();
@@ -406,6 +383,26 @@ QHash<int, QByteArray> RoomListModel::roleNames() const
return roles;
}
NeoChatRoomType::Types RoomListModel::category(NeoChatRoom *room)
{
if (room->isSpace()) {
return NeoChatRoomType::Space;
}
if (room->joinState() == JoinState::Invite) {
return NeoChatRoomType::Invited;
}
if (room->isFavourite()) {
return NeoChatRoomType::Favorite;
}
if (room->isLowPriority()) {
return NeoChatRoomType::Deprioritized;
}
if (room->isDirectChat()) {
return NeoChatRoomType::Direct;
}
return NeoChatRoomType::Normal;
}
QString RoomListModel::categoryName(int category)
{
switch (category) {