Compare commits
1 Commits
master
...
work/tobia
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60ce292b58 |
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <Quotient/csapi/space_hierarchy.h>
|
#include <Quotient/csapi/space_hierarchy.h>
|
||||||
#include <Quotient/qt_connection_util.h>
|
#include <Quotient/qt_connection_util.h>
|
||||||
|
#include <Quotient/quotient_common.h>
|
||||||
|
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KSharedConfig>
|
#include <KSharedConfig>
|
||||||
@@ -50,11 +51,33 @@ void SpaceHierarchyCache::cacheSpaceHierarchy()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpaceHierarchyCache::populateFromState(const QString &spaceId, const QString &rootId)
|
||||||
|
{
|
||||||
|
if (const auto &room = m_connection->room(spaceId)) {
|
||||||
|
for (const auto &event : room->currentState().eventsOfType("m.space.child"_ls)) {
|
||||||
|
if (const auto &child = m_connection->room(event->stateKey())) {
|
||||||
|
m_spaceHierarchy[rootId] += event->stateKey();
|
||||||
|
auto successor = child;
|
||||||
|
do {
|
||||||
|
m_spaceHierarchy[rootId] += successor->id();
|
||||||
|
} while ((successor = successor->successor(JoinState::Join)));
|
||||||
|
if (dynamic_cast<NeoChatRoom *>(child)->isSpace()) {
|
||||||
|
populateFromState(child->id(), rootId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Q_EMIT spaceHierarchyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void SpaceHierarchyCache::populateSpaceHierarchy(const QString &spaceId)
|
void SpaceHierarchyCache::populateSpaceHierarchy(const QString &spaceId)
|
||||||
{
|
{
|
||||||
if (!m_connection) {
|
if (!m_connection) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
populateFromState(spaceId, spaceId);
|
||||||
|
|
||||||
auto job = m_connection->callApi<GetSpaceHierarchyJob>(spaceId);
|
auto job = m_connection->callApi<GetSpaceHierarchyJob>(spaceId);
|
||||||
|
|
||||||
connect(job, &BaseJob::success, this, [this, job, spaceId]() {
|
connect(job, &BaseJob::success, this, [this, job, spaceId]() {
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ private Q_SLOTS:
|
|||||||
private:
|
private:
|
||||||
explicit SpaceHierarchyCache(QObject *parent = nullptr);
|
explicit SpaceHierarchyCache(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
void populateFromState(const QString &roomId, const QString &rootId);
|
||||||
|
|
||||||
QList<QString> m_activeSpaceRooms;
|
QList<QString> m_activeSpaceRooms;
|
||||||
QHash<QString, QList<QString>> m_spaceHierarchy;
|
QHash<QString, QList<QString>> m_spaceHierarchy;
|
||||||
void cacheSpaceHierarchy();
|
void cacheSpaceHierarchy();
|
||||||
|
|||||||
Reference in New Issue
Block a user