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()) {
|
||||
return room->member(QString());
|
||||
}
|
||||
const auto evtIt = room->findInTimeline(m_relationId);
|
||||
if (evtIt != room->messageEvents().rend()) {
|
||||
return room->member((*evtIt)->senderId());
|
||||
const auto [event, _] = room->getEvent(m_relationId);
|
||||
if (event != nullptr) {
|
||||
return room->member(event->senderId());
|
||||
}
|
||||
qWarning() << "Failed to find relation" << m_relationId << "in timeline?";
|
||||
return room->member(QString());
|
||||
@@ -178,8 +178,8 @@ QString ChatBarCache::relationMessage() const
|
||||
return {};
|
||||
}
|
||||
|
||||
if (auto event = room->findInTimeline(m_relationId); event != room->historyEdge()) {
|
||||
return EventHandler::markdownBody(&**event);
|
||||
if (auto [event, _] = room->getEvent(m_relationId); event != nullptr) {
|
||||
return EventHandler::markdownBody(event);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -285,11 +285,6 @@ void ChatBarCache::postMessage()
|
||||
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);
|
||||
|
||||
room->post<Quotient::RoomMessageEvent>(text(), *std::get<std::optional<Quotient::RoomMessageEvent::MsgType>>(result), std::move(content), relatesTo);
|
||||
|
||||
Reference in New Issue
Block a user