Fix external quote-reply to topic message.

This commit is contained in:
John Preston 2023-10-31 09:01:01 +04:00
parent d1c310de00
commit 475b2ac739
6 changed files with 27 additions and 10 deletions

View File

@ -2090,6 +2090,7 @@ void ListWidget::paintEvent(QPaintEvent *e) {
});
auto context = preparePaintContext(clip);
context.highlightPathCache = &_highlightPathCache;
if (from == end(_items)) {
_delegate->listPaintEmpty(p, context);
return;

View File

@ -649,6 +649,7 @@ private:
base::flat_map<MsgId, Ui::PeerUserpicView> _hiddenSenderUserpics;
const std::unique_ptr<Ui::PathShiftGradient> _pathGradient;
QPainterPath _highlightPathCache;
base::unique_qptr<Ui::RpWidget> _emptyInfo = nullptr;

View File

@ -1123,6 +1123,8 @@ void Message::draw(Painter &p, const PaintContext &context) const {
const auto mediaSelection = _invertMedia
? context.selection
: skipTextSelection(context.selection);
const auto maybeMediaHighlight = context.highlightPathCache
&& context.highlightPathCache->isEmpty();
auto mediaPosition = QPoint(inner.left(), top);
p.translate(mediaPosition);
media->draw(p, context.translated(
@ -1135,7 +1137,7 @@ void Message::draw(Painter &p, const PaintContext &context) const {
context.reactionInfo->effectOffset -= add;
}
}
if (context.highlightPathCache
if (maybeMediaHighlight
&& !context.highlightPathCache->isEmpty()) {
context.highlightPathCache->translate(mediaPosition);
}

View File

@ -128,10 +128,12 @@ rpl::producer<Ui::MessageBarContent> RootViewContent(
RepliesMemento::RepliesMemento(
not_null<History*> history,
MsgId rootId,
MsgId highlightId)
MsgId highlightId,
const TextWithEntities &highlightPart)
: _history(history)
, _rootId(rootId)
, _highlightId(highlightId) {
, _highlightId(highlightId)
, _highlightPart(highlightPart) {
if (highlightId) {
_list.setAroundPosition({
.fullId = FullMsgId(_history->peer->id, highlightId),
@ -1966,7 +1968,7 @@ bool RepliesWidget::showInternal(
if (logMemento->getHistory() == history()
&& logMemento->getRootId() == _rootId) {
restoreState(logMemento);
if (!logMemento->getHighlightId()) {
if (!logMemento->highlightId()) {
showAtPosition(Data::UnreadMessagePosition);
}
if (params.reapplyLocalDraft) {
@ -2033,7 +2035,8 @@ bool RepliesWidget::showMessage(
if (!originMessage) {
return false;
}
const auto originItemId = (_cornerButtons.replyReturn() != originMessage)
const auto currentReplyReturn = _cornerButtons.replyReturn();
const auto originItemId = (currentReplyReturn != originMessage)
? originMessage->fullId()
: FullMsgId();
showAtPosition(message->position(), originItemId, params);
@ -2138,11 +2141,15 @@ void RepliesWidget::restoreState(not_null<RepliesMemento*> memento) {
}
_cornerButtons.setReplyReturns(memento->replyReturns());
_inner->restoreState(memento->list());
if (const auto highlight = memento->getHighlightId()) {
if (const auto highlight = memento->highlightId()) {
auto params = Window::SectionShow(
Window::SectionShow::Way::Forward,
anim::type::instant);
params.highlightPart = memento->highlightPart();
showAtPosition(Data::MessagePosition{
.fullId = FullMsgId(_history->peer->id, highlight),
.date = TimeId(0),
}, {}, { Window::SectionShow::Way::Forward, anim::type::instant });
}, {}, params);
}
}

View File

@ -380,7 +380,8 @@ public:
RepliesMemento(
not_null<History*> history,
MsgId rootId,
MsgId highlightId = 0);
MsgId highlightId = 0,
const TextWithEntities &highlightPart = {});
explicit RepliesMemento(
not_null<HistoryItem*> commentsItem,
MsgId commentId = 0);
@ -424,9 +425,12 @@ public:
[[nodiscard]] not_null<ListMemento*> list() {
return &_list;
}
[[nodiscard]] MsgId getHighlightId() const {
[[nodiscard]] MsgId highlightId() const {
return _highlightId;
}
[[nodiscard]] const TextWithEntities &highlightPart() const {
return _highlightPart;
}
private:
void setupTopicViewer();
@ -434,6 +438,7 @@ private:
const not_null<History*> _history;
MsgId _rootId = 0;
const MsgId _highlightId = 0;
const TextWithEntities _highlightPart;
ListMemento _list;
std::shared_ptr<Data::RepliesList> _replies;
QVector<FullMsgId> _replyReturns;

View File

@ -850,7 +850,8 @@ void SessionNavigation::showRepliesForMessage(
auto memento = std::make_shared<HistoryView::RepliesMemento>(
history,
rootId,
commentId);
commentId,
params.highlightPart);
memento->setFromTopic(topic);
showSection(std::move(memento), params);
return;