Move the storage of thread models to the room

This commit is contained in:
James Graham
2025-01-11 12:14:31 +00:00
parent 37de1ec583
commit ae7bfa5bcb
4 changed files with 25 additions and 7 deletions

View File

@@ -174,6 +174,7 @@ void NeoChatRoom::setVisible(bool visible)
if (!visible) {
m_memberObjects.clear();
m_eventContentModels.clear();
m_threadModels.clear();
}
}
@@ -1797,4 +1798,17 @@ MessageContentModel *NeoChatRoom::contentModelForEvent(const QString &evtOrTxnId
return nullptr;
}
ThreadModel *NeoChatRoom::modelForThread(const QString &threadRootId)
{
if (threadRootId.isEmpty()) {
return nullptr;
}
if (!m_threadModels.contains(threadRootId)) {
return m_threadModels.emplace(threadRootId, std::make_unique<ThreadModel>(threadRootId, this)).first->second.get();
}
return m_threadModels[threadRootId].get();
}
#include "moc_neochatroom.cpp"