Release threads removing the feature flag.

This mr performs some final cleanup to make sure the threads are sized correctly and it all works with the new chatbar
This commit is contained in:
James Graham
2026-02-15 15:26:49 +00:00
committed by Joshua Goins
parent 85b731e9fb
commit 7e6b79d5d4
18 changed files with 60 additions and 93 deletions

View File

@@ -9,6 +9,7 @@ ecm_add_qml_module(MessageContent GENERATE_PLUGIN_SOURCE
BaseMessageComponentChooser.qml
MessageComponentChooser.qml
ReplyMessageComponentChooser.qml
ThreadBodyMessageComponentChooser.qml
AuthorComponent.qml
AudioComponent.qml
CodeComponent.qml

View File

@@ -29,10 +29,16 @@ BaseMessageComponentChooser {
DelegateChoice {
roleValue: MessageComponentType.ChatBar
delegate: ChatBarCore {
/**
* @brief The ChatBarCache to use.
*/
required property ChatBarCache chatBarCache
Layout.fillWidth: true
Layout.maximumWidth: Message.maxContentWidth
room: Message.room
chatBarType: LibNeoChat.ChatBarType.Edit
chatBarType: chatBarCache.isEditing ? LibNeoChat.ChatBarType.Edit : LibNeoChat.ChatBarType.Thread
maxAvailableWidth: Message.maxContentWidth
}
}

View File

@@ -40,7 +40,7 @@ ColumnLayout {
id: threadRepeater
model: root.Message.contentModel.modelForThread(root.threadRoot);
delegate: BaseMessageComponentChooser {
delegate: ThreadBodyMessageComponentChooser {
onSelectedTextChanged: selectedText => {
root.selectedTextChanged(selectedText);
}

View File

@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: 2026 James Graham <james.h.graham@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick
import QtQuick.Layouts
import Qt.labs.qmlmodels
import org.kde.neochat
import org.kde.neochat.libneochat as LibNeoChat
/**
* @brief Select a message component based on a MessageComponentType.
*/
BaseMessageComponentChooser {
id: root
DelegateChoice {
roleValue: MessageComponentType.ChatBar
delegate: ChatBarCore {
Layout.fillWidth: true
Layout.maximumWidth: Message.maxContentWidth
room: Message.room
chatBarType: LibNeoChat.ChatBarType.Thread
maxAvailableWidth: Message.maxContentWidth
}
}
}

View File

@@ -113,13 +113,4 @@ PollHandler *ContentProvider::handlerForPoll(NeoChatRoom *room, const QString &e
return m_pollHandlers.object(eventId);
}
void ContentProvider::setThreadsEnabled(bool enableThreads)
{
EventMessageContentModel::setThreadsEnabled(enableThreads);
for (const auto &key : m_eventContentModels.keys()) {
m_eventContentModels.object(key)->threadsEnabledChanged();
}
}
#include "moc_contentprovider.cpp"

View File

@@ -81,8 +81,6 @@ public:
*/
Q_INVOKABLE PollHandler *handlerForPoll(NeoChatRoom *room, const QString &eventId);
void setThreadsEnabled(bool enableThreads);
private:
explicit ContentProvider(QObject *parent = nullptr);

View File

@@ -22,8 +22,6 @@
using namespace Quotient;
bool EventMessageContentModel::m_threadsEnabled = false;
EventMessageContentModel::EventMessageContentModel(NeoChatRoom *room, const QString &eventId, bool isReply, bool isPending, MessageContentModel *parent)
: MessageContentModel(room, eventId, parent)
, m_currentState(isPending ? Pending : Unknown)
@@ -104,9 +102,6 @@ void EventMessageContentModel::initializeModel()
}
}
});
connect(this, &EventMessageContentModel::threadsEnabledChanged, this, [this]() {
resetModel();
});
connect(m_room, &Room::updatedEvent, this, [this](const QString &eventId) {
if (eventId == m_eventId) {
updateReactionModel();
@@ -304,7 +299,7 @@ QList<MessageComponent> EventMessageContentModel::messageContentComponents(bool
}
const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event.first);
if (m_threadsEnabled && roomMessageEvent
if (roomMessageEvent
&& ((roomMessageEvent->isThreaded() && roomMessageEvent->id() == roomMessageEvent->threadRootEventId())
|| m_room->threads().contains(roomMessageEvent->id()))) {
newComponents += MessageComponent{MessageComponentType::Separator, {}, {}};
@@ -328,14 +323,14 @@ std::optional<QString> EventMessageContentModel::getReplyEventId()
if (roomMessageEvent == nullptr) {
return std::nullopt;
}
if (!roomMessageEvent->isReply(!m_threadsEnabled)) {
if (!roomMessageEvent->isReply()) {
if (m_replyModel) {
m_replyModel->disconnect(this);
m_replyModel->deleteLater();
}
return std::nullopt;
}
return roomMessageEvent->isReply(!m_threadsEnabled) ? std::make_optional(roomMessageEvent->replyEventId(!m_threadsEnabled)) : std::nullopt;
return roomMessageEvent->isReply() ? std::make_optional(roomMessageEvent->replyEventId()) : std::nullopt;
}
QList<MessageComponent> EventMessageContentModel::componentsForType(MessageComponentType::Type type)
@@ -475,9 +470,4 @@ ThreadModel *EventMessageContentModel::modelForThread(const QString &threadRootI
return ContentProvider::self().modelForThread(m_room, threadRootId);
}
void EventMessageContentModel::setThreadsEnabled(bool enableThreads)
{
m_threadsEnabled = enableThreads;
}
#include "moc_eventmessagecontentmodel.cpp"

View File

@@ -43,11 +43,8 @@ public:
*/
Q_INVOKABLE ThreadModel *modelForThread(const QString &threadRootId);
static void setThreadsEnabled(bool enableThreads);
Q_SIGNALS:
void eventUpdated();
void threadsEnabledChanged();
private:
void initializeModel();
@@ -74,6 +71,4 @@ private:
void updateItineraryModel();
void updateReactionModel();
static bool m_threadsEnabled;
};