fix: replies in topics for message shot

This commit is contained in:
AlexeyZavar 2024-03-13 15:19:38 +03:00
parent c525fd64ca
commit 1935a2b144

View file

@ -13,12 +13,14 @@
#include "ayu/ui/boxes/message_shot_box.h" #include "ayu/ui/boxes/message_shot_box.h"
#include "boxes/abstract_box.h" #include "boxes/abstract_box.h"
#include "data/data_cloud_themes.h" #include "data/data_cloud_themes.h"
#include "data/data_forum.h"
#include "data/data_peer.h" #include "data/data_peer.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "history/history.h" #include "history/history.h"
#include "history/history_inner_widget.h" #include "history/history_inner_widget.h"
#include "history/history_item.h" #include "history/history_item.h"
#include "history/view/history_view_element.h" #include "history/view/history_view_element.h"
#include "history/history_item_components.h"
#include "history/view/media/history_view_media.h" #include "history/view/media/history_view_media.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
@ -152,27 +154,28 @@ public:
not_null<QWidget*> parent, not_null<QWidget*> parent,
not_null<Ui::ChatStyle*> st, not_null<Ui::ChatStyle*> st,
Fn<void()> update, Fn<void()> update,
bool isTopic); not_null<History*> history);
bool elementAnimationsPaused() override; bool elementAnimationsPaused() override;
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override; not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
HistoryView::Context elementContext() override; HistoryView::Context elementContext() override;
bool elementHideReply(not_null<const HistoryView::Element*> view) override;
bool elementIsChatWide() override; bool elementIsChatWide() override;
private: private:
const not_null<QWidget*> _parent; const not_null<QWidget*> _parent;
const std::unique_ptr<Ui::PathShiftGradient> _pathGradient; const std::unique_ptr<Ui::PathShiftGradient> _pathGradient;
HistoryView::Context _context; not_null<History*> _history;
}; };
MessageShotDelegate::MessageShotDelegate( MessageShotDelegate::MessageShotDelegate(
not_null<QWidget*> parent, not_null<QWidget*> parent,
not_null<Ui::ChatStyle*> st, not_null<Ui::ChatStyle*> st,
Fn<void()> update, Fn<void()> update,
bool isTopic) not_null<History*> history)
: _parent(parent) : _parent(parent)
, _pathGradient(HistoryView::MakePathShiftGradient(st, update)) { , _pathGradient(HistoryView::MakePathShiftGradient(st, update))
_context = isTopic ? HistoryView::Context::Replies : HistoryView::Context::AdminLog; , _history(history) {
} }
bool MessageShotDelegate::elementAnimationsPaused() { bool MessageShotDelegate::elementAnimationsPaused() {
@ -188,6 +191,21 @@ HistoryView::Context MessageShotDelegate::elementContext() {
return HistoryView::Context::AdminLog; return HistoryView::Context::AdminLog;
} }
bool MessageShotDelegate::elementHideReply(not_null<const HistoryView::Element*> view) {
if (const auto reply = view->data()->Get<HistoryMessageReply>()) {
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() { bool MessageShotDelegate::elementIsChatWide() {
return true; return true;
} }
@ -267,7 +285,7 @@ QImage Make(not_null<QWidget*> box, const ShotConfig &config) {
{ {
box->update(); box->update();
}, },
messages.front()->history()->asTopic()); messages.front()->history());
// remove deleted messages // remove deleted messages
messages.erase( messages.erase(