Add a button to mark spaces as read
[BUG: 508122](https://bugs.kde.org/show_bug.cgi?id=508122)
This commit is contained in:
committed by
Joshua Goins
parent
fb8ee02e3b
commit
ade5750550
@@ -187,6 +187,21 @@ bool SpaceHierarchyCache::isChild(const QString &roomId) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SpaceHierarchyCache::spaceHasUnreadMessages(const QString &spaceId)
|
||||
{
|
||||
auto children = m_spaceHierarchy[spaceId];
|
||||
|
||||
for (const auto &childId : children) {
|
||||
if (const auto child = static_cast<NeoChatRoom *>(m_connection->room(childId))) {
|
||||
if (child->notificationCount() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NeoChatConnection *SpaceHierarchyCache::connection() const
|
||||
{
|
||||
return m_connection;
|
||||
@@ -239,4 +254,40 @@ void SpaceHierarchyCache::setRecommendedSpaceHidden(bool hidden)
|
||||
Q_EMIT recommendedSpaceHiddenChanged();
|
||||
}
|
||||
|
||||
void SpaceHierarchyCache::markAllChildrenMessagesAsRead(const QString &spaceId)
|
||||
{
|
||||
const auto children = m_spaceHierarchy[spaceId];
|
||||
|
||||
for (const auto &childId : children) {
|
||||
if (const auto child = static_cast<NeoChatRoom *>(m_connection->room(childId))) {
|
||||
if (child->notificationCount() <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (child->messageEvents().crbegin() == child->historyEdge()) {
|
||||
if (!child->eventsHistoryJob()) {
|
||||
if (child->allHistoryLoaded()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
child->getPreviousContent();
|
||||
}
|
||||
|
||||
connect(
|
||||
child,
|
||||
&NeoChatRoom::addedMessages,
|
||||
child,
|
||||
[child] {
|
||||
if (child->messageEvents().crbegin() != child->historyEdge()) {
|
||||
child->markAllMessagesAsRead();
|
||||
}
|
||||
},
|
||||
Qt::SingleShotConnection);
|
||||
} else {
|
||||
child->markAllMessagesAsRead();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_spacehierarchycache.cpp"
|
||||
|
||||
Reference in New Issue
Block a user