From 1935a2b1447f90d5457788246162e8911e249ee4 Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Wed, 13 Mar 2024 15:19:38 +0300 Subject: [PATCH] fix: replies in topics for message shot --- .../ayu/features/messageshot/message_shot.cpp | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/ayu/features/messageshot/message_shot.cpp b/Telegram/SourceFiles/ayu/features/messageshot/message_shot.cpp index ef107ff78..d6ba46cbb 100644 --- a/Telegram/SourceFiles/ayu/features/messageshot/message_shot.cpp +++ b/Telegram/SourceFiles/ayu/features/messageshot/message_shot.cpp @@ -13,12 +13,14 @@ #include "ayu/ui/boxes/message_shot_box.h" #include "boxes/abstract_box.h" #include "data/data_cloud_themes.h" +#include "data/data_forum.h" #include "data/data_peer.h" #include "data/data_session.h" #include "history/history.h" #include "history/history_inner_widget.h" #include "history/history_item.h" #include "history/view/history_view_element.h" +#include "history/history_item_components.h" #include "history/view/media/history_view_media.h" #include "main/main_session.h" #include "styles/style_chat.h" @@ -152,27 +154,28 @@ public: not_null parent, not_null st, Fn update, - bool isTopic); + not_null history); bool elementAnimationsPaused() override; not_null elementPathShiftGradient() override; HistoryView::Context elementContext() override; + bool elementHideReply(not_null view) override; bool elementIsChatWide() override; private: const not_null _parent; const std::unique_ptr _pathGradient; - HistoryView::Context _context; + not_null _history; }; MessageShotDelegate::MessageShotDelegate( not_null parent, not_null st, Fn update, - bool isTopic) + not_null history) : _parent(parent) - , _pathGradient(HistoryView::MakePathShiftGradient(st, update)) { - _context = isTopic ? HistoryView::Context::Replies : HistoryView::Context::AdminLog; + , _pathGradient(HistoryView::MakePathShiftGradient(st, update)) + , _history(history) { } bool MessageShotDelegate::elementAnimationsPaused() { @@ -188,6 +191,21 @@ HistoryView::Context MessageShotDelegate::elementContext() { return HistoryView::Context::AdminLog; } +bool MessageShotDelegate::elementHideReply(not_null view) { + if (const auto reply = view->data()->Get()) { + const auto replyToPeerId = reply->externalPeerId() + ? reply->externalPeerId() + : _history->peer->id; + + if (reply->fields().manualQuote) { + return false; + } else if (replyToPeerId == _history->peer->id) { + return _history->asForum() && _history->asForum()->topicFor(reply->messageId()); + } + } + return false; +} + bool MessageShotDelegate::elementIsChatWide() { return true; } @@ -267,7 +285,7 @@ QImage Make(not_null box, const ShotConfig &config) { { box->update(); }, - messages.front()->history()->asTopic()); + messages.front()->history()); // remove deleted messages messages.erase(