Thread View

So at the moment this remains behind the feature flag as this only adds a threadmodel and a basic visualisation. There is much more to come to get it ready for full release.
This commit is contained in:
James Graham
2024-08-18 15:19:03 +00:00
parent 149013d2ff
commit 56d790dda9
17 changed files with 347 additions and 23 deletions

View File

@@ -64,6 +64,7 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
{
m_mainCache = new ChatBarCache(this);
m_editCache = new ChatBarCache(this);
m_threadCache = new ChatBarCache(this);
connect(connection, &Connection::accountDataChanged, this, &NeoChatRoom::updatePushNotificationState);
connect(this, &Room::fileTransferCompleted, this, [this] {
@@ -516,9 +517,10 @@ void NeoChatRoom::postMessage(const QString &rawText,
MessageEventType type,
const QString &replyEventId,
const QString &relateToEventId,
const QString &threadRootId)
const QString &threadRootId,
const QString &fallbackId)
{
postHtmlMessage(rawText, text, type, replyEventId, relateToEventId, threadRootId);
postHtmlMessage(rawText, text, type, replyEventId, relateToEventId, threadRootId, fallbackId);
}
void NeoChatRoom::postHtmlMessage(const QString &text,
@@ -526,7 +528,8 @@ void NeoChatRoom::postHtmlMessage(const QString &text,
MessageEventType type,
const QString &replyEventId,
const QString &relateToEventId,
const QString &threadRootId)
const QString &threadRootId,
const QString &fallbackId)
{
bool isReply = !replyEventId.isEmpty();
bool isEdit = !relateToEventId.isEmpty();
@@ -537,9 +540,21 @@ void NeoChatRoom::postHtmlMessage(const QString &text,
}
if (isThread) {
EventHandler eventHandler(this, &**replyIt);
bool isFallingBack = !fallbackId.isEmpty();
QString replyEventId = isFallingBack ? fallbackId : QString();
if (isReply) {
EventHandler eventHandler(this, &**replyIt);
const bool isFallingBack = !eventHandler.isThreaded();
isFallingBack = false;
replyEventId = eventHandler.getId();
}
// If we are not replying and there is no fallback ID it means a new thread
// is being created.
if (!isFallingBack && !isReply) {
isFallingBack = true;
replyEventId = threadRootId;
}
// clang-format off
QJsonObject json{
@@ -1532,6 +1547,11 @@ ChatBarCache *NeoChatRoom::editCache() const
return m_editCache;
}
ChatBarCache *NeoChatRoom::threadCache() const
{
return m_threadCache;
}
void NeoChatRoom::replyLastMessage()
{
const auto &timelineBottom = messageEvents().rbegin();