Merge pull request #1062 from Nheko-Reborn/perSpaceNotifs
Per-space notification bubbles
1 files changed, 14 insertions, 8 deletions
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp
index 1cf16243..1869d2e0 100644
--- a/src/timeline/RoomlistModel.cpp
+++ b/src/timeline/RoomlistModel.cpp
@@ -330,10 +330,13 @@ RoomlistModel::addRoom(const QString &room_id, bool suppressInsertNotification)
Qt::DisplayRole,
});
+ if (getRoomById(room_id)->isSpace())
+ return; // no need to update space notifications
+
int total_unread_msgs = 0;
for (const auto &room : qAsConst(models)) {
- if (!room.isNull())
+ if (!room.isNull() && !room->isSpace())
total_unread_msgs += room->notificationCount();
}
@@ -639,15 +642,18 @@ RoomlistModel::clear()
}
void
-RoomlistModel::joinPreview(QString roomid, QString parentSpace)
+RoomlistModel::joinPreview(QString roomid)
{
if (previewedRooms.contains(roomid)) {
- auto child = cache::client()->getStateEvent<mtx::events::state::space::Child>(
- parentSpace.toStdString(), roomid.toStdString());
- ChatPage::instance()->joinRoomVia(
- roomid.toStdString(),
- (child && child->content.via) ? child->content.via.value() : std::vector<std::string>{},
- false);
+ std::vector<std::string> vias;
+ auto parents = cache::client()->getParentRoomIds(roomid.toStdString());
+ for (const auto &p : parents) {
+ auto child = cache::client()->getStateEvent<mtx::events::state::space::Child>(
+ p, roomid.toStdString());
+ if (child && child->content.via)
+ vias.insert(vias.end(), child->content.via->begin(), child->content.via->end());
+ }
+ ChatPage::instance()->joinRoomVia(roomid.toStdString(), vias, false);
}
}
void
|