Always show manual quote replies, hide redundant.

This commit is contained in:
John Preston 2023-11-06 12:35:08 +04:00
parent 5350c97f82
commit d7539349c7
6 changed files with 33 additions and 17 deletions

View file

@ -260,7 +260,11 @@ public:
return _widget ? _widget->elementAnimationsPaused() : false;
}
bool elementHideReply(not_null<const Element*> view) override {
return view->isTopicRootReply();
if (!view->isTopicRootReply()) {
return false;
}
const auto reply = view->data()->Get<HistoryMessageReply>();
return reply && !reply->fields().manualQuote;
}
bool elementShownUnread(not_null<const Element*> view) override {
return view->data()->unread(view->data()->history());

View file

@ -498,7 +498,8 @@ Element::Element(
| Flag::NeedsResize
| (IsItemScheduledUntilOnline(data)
? Flag::ScheduledUntilOnline
: Flag()))
: Flag())
| (countIsTopicRootReply() ? Flag::TopicRootReply : Flag()))
, _context(delegate->elementContext()) {
history()->owner().registerItemView(this);
refreshMedia(replacing);
@ -1260,15 +1261,6 @@ QSize Element::countCurrentSize(int newWidth) {
return performCountCurrentSize(newWidth);
}
void Element::refreshIsTopicRootReply() {
const auto topicRootReply = countIsTopicRootReply();
if (topicRootReply) {
_flags |= Flag::TopicRootReply;
} else {
_flags &= ~Flag::TopicRootReply;
}
}
bool Element::countIsTopicRootReply() const {
const auto item = data();
if (!item->history()->isForum()) {

View file

@ -565,7 +565,6 @@ protected:
void clearSpecialOnlyEmoji();
void checkSpecialOnlyEmoji();
void refreshIsTopicRootReply();
private:
// This should be called only from previousInBlocksChanged()

View file

@ -601,7 +601,7 @@ QSize Message::performCountOptimalSize() {
const auto item = data();
const auto replyData = item->Get<HistoryMessageReply>();
if (replyData) {
if (replyData && !_hideReply) {
AddComponents(Reply::Bit());
} else {
RemoveComponents(Reply::Bit());
@ -616,7 +616,6 @@ QSize Message::performCountOptimalSize() {
: 2;
};
const auto oldKey = reactionsKey();
refreshIsTopicRootReply();
validateText();
validateInlineKeyboard(markup);
updateViewButtonExistence();

View file

@ -597,7 +597,11 @@ void PinnedWidget::listUpdateDateLink(
}
bool PinnedWidget::listElementHideReply(not_null<const Element*> view) {
return (view->data()->replyToId() == _thread->topicRootId());
if (const auto reply = view->data()->Get<HistoryMessageReply>()) {
return !reply->fields().manualQuote
&& (reply->messageId() == _thread->topicRootId());
}
return false;
}
bool PinnedWidget::listElementShownUnread(not_null<const Element*> view) {

View file

@ -2020,7 +2020,7 @@ bool RepliesWidget::showMessage(
}
const auto id = FullMsgId(_history->peer->id, messageId);
const auto message = _history->owner().message(id);
if (!message || !message->inThread(_rootId)) {
if (!message || (!message->inThread(_rootId) && id.msg != _rootId)) {
return false;
}
const auto originMessage = [&]() -> HistoryItem* {
@ -2516,7 +2516,25 @@ void RepliesWidget::listUpdateDateLink(
}
bool RepliesWidget::listElementHideReply(not_null<const Element*> view) {
return (view->data()->replyToId() == _rootId);
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 (reply->messageId() == _rootId);
} else if (_root) {
const auto forwarded = _root->Get<HistoryMessageForwarded>();
if (forwarded
&& forwarded->savedFromPeer
&& forwarded->savedFromPeer->id == replyToPeerId
&& forwarded->savedFromMsgId == reply->messageId()) {
return true;
}
}
}
return false;
}
bool RepliesWidget::listElementShownUnread(not_null<const Element*> view) {