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

@@ -42,6 +42,7 @@
#include "neochatconfig.h"
#include "notificationsmanager.h"
#include "roomlastmessageprovider.h"
#include "spacehierarchycache.h"
#include "texthandler.h"
#include "urlhelper.h"
#include "utils.h"
@@ -125,6 +126,16 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
Q_EMIT urlPreviewEnabledChanged();
}
});
connect(&SpaceHierarchyCache::instance(), &SpaceHierarchyCache::spaceHierarchyChanged, this, [this]() {
if (isSpace()) {
Q_EMIT childrenNotificationCountChanged();
}
});
connect(&SpaceHierarchyCache::instance(), &SpaceHierarchyCache::spaceNotifcationCountChanged, this, [this](const QStringList &spaces) {
if (spaces.contains(id())) {
Q_EMIT childrenNotificationCountChanged();
}
});
}
bool NeoChatRoom::hasFileUploading() const
@@ -1278,6 +1289,14 @@ bool NeoChatRoom::isSpace()
return creationEvent->roomType() == RoomType::Space;
}
qsizetype NeoChatRoom::childrenNotificationCount()
{
if (!isSpace()) {
return 0;
}
return SpaceHierarchyCache::instance().notificationCountForSpace(id());
}
void NeoChatRoom::addChild(const QString &childId, bool setChildParent, bool canonical, bool suggested)
{
if (!isSpace()) {