Support replying and editing messages directly from room search
There's two parts to making this work mainly: 1. Use getEvent instead of findInTimeline so the related event is actually found. 2. Close the dialog once a reply relation is found, so you can easily reply in the chat bar.
This commit is contained in:
@@ -150,9 +150,9 @@ Quotient::RoomMember ChatBarCache::relationAuthor() const
|
|||||||
if (m_relationId.isEmpty()) {
|
if (m_relationId.isEmpty()) {
|
||||||
return room->member(QString());
|
return room->member(QString());
|
||||||
}
|
}
|
||||||
const auto evtIt = room->findInTimeline(m_relationId);
|
const auto [event, _] = room->getEvent(m_relationId);
|
||||||
if (evtIt != room->messageEvents().rend()) {
|
if (event != nullptr) {
|
||||||
return room->member((*evtIt)->senderId());
|
return room->member(event->senderId());
|
||||||
}
|
}
|
||||||
qWarning() << "Failed to find relation" << m_relationId << "in timeline?";
|
qWarning() << "Failed to find relation" << m_relationId << "in timeline?";
|
||||||
return room->member(QString());
|
return room->member(QString());
|
||||||
@@ -178,8 +178,8 @@ QString ChatBarCache::relationMessage() const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto event = room->findInTimeline(m_relationId); event != room->historyEdge()) {
|
if (auto [event, _] = room->getEvent(m_relationId); event != nullptr) {
|
||||||
return EventHandler::markdownBody(&**event);
|
return EventHandler::markdownBody(event);
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -285,11 +285,6 @@ void ChatBarCache::postMessage()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto replyIt = room->findInTimeline(replyId());
|
|
||||||
if (replyIt == room->historyEdge()) {
|
|
||||||
isReply = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto content = std::make_unique<Quotient::EventContent::TextContent>(sendText, u"text/html"_s);
|
auto content = std::make_unique<Quotient::EventContent::TextContent>(sendText, u"text/html"_s);
|
||||||
|
|
||||||
room->post<Quotient::RoomMessageEvent>(text(), *std::get<std::optional<Quotient::RoomMessageEvent::MsgType>>(result), std::move(content), relatesTo);
|
room->post<Quotient::RoomMessageEvent>(text(), *std::get<std::optional<Quotient::RoomMessageEvent::MsgType>>(result), std::move(content), relatesTo);
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
import org.kde.neochat.libneochat
|
import org.kde.neochat.libneochat
|
||||||
import org.kde.neochat.timeline
|
import org.kde.neochat.timeline
|
||||||
|
|
||||||
@@ -45,4 +47,15 @@ SearchPage {
|
|||||||
noResultPlaceholderMessage: i18n("No messages found")
|
noResultPlaceholderMessage: i18n("No messages found")
|
||||||
|
|
||||||
listVerticalLayoutDirection: ListView.BottomToTop
|
listVerticalLayoutDirection: ListView.BottomToTop
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: root.room.mainCache
|
||||||
|
|
||||||
|
function onRelationIdChanged(oldEventId: string, newEventId: string): void {
|
||||||
|
// If we start replying/editing an event, we need to close the search dialog so the user can type.
|
||||||
|
if (newEventId.length > 0) {
|
||||||
|
root.Kirigami.PageStack.closeDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ MessageDelegateBase {
|
|||||||
quickActionComponent: QuickActions {
|
quickActionComponent: QuickActions {
|
||||||
room: root.room
|
room: root.room
|
||||||
eventId: root.eventId
|
eventId: root.eventId
|
||||||
|
author: root.author
|
||||||
}
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
|
|||||||
@@ -22,6 +22,15 @@ RowLayout {
|
|||||||
*/
|
*/
|
||||||
required property string eventId
|
required property string eventId
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The message author.
|
||||||
|
*
|
||||||
|
* A Quotient::RoomMember object.
|
||||||
|
*
|
||||||
|
* @sa Quotient::RoomMember
|
||||||
|
*/
|
||||||
|
required property var author
|
||||||
|
|
||||||
property real availableWidth: 0.0
|
property real availableWidth: 0.0
|
||||||
|
|
||||||
property bool reacting: false
|
property bool reacting: false
|
||||||
|
|||||||
Reference in New Issue
Block a user