diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index f2fd9a233..52e1bcdf3 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1357,6 +1357,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_comments_open_count#one" = "{count} comment"; "lng_comments_open_count#other" = "{count} comments"; "lng_comments_open_none" = "Leave a comment"; +"lng_replies_view_original" = "View reply"; "lng_replies_messages" = "Replies"; "lng_archived_name" = "Archived chats"; diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index a903cc45b..0871e3642 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -198,6 +198,9 @@ public: [[nodiscard]] virtual bool repliesAreComments() const { return false; } + [[nodiscard]] virtual bool externalReply() const { + return false; + } [[nodiscard]] virtual FullMsgId commentsItemId() const { return FullMsgId(); } diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index e8ced5d34..7cb57da04 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -790,6 +790,15 @@ bool HistoryMessage::repliesAreComments() const { return HistoryItem::repliesAreComments(); } +bool HistoryMessage::externalReply() const { + if (!history()->peer->isRepliesChat()) { + return false; + } else if (const auto forwarded = Get()) { + return forwarded->savedFromPeer && forwarded->savedFromMsgId; + } + return false; +} + FullMsgId HistoryMessage::commentsItemId() const { if (const auto views = Get()) { return FullMsgId(views->commentsChannelId, views->commentsRootId); diff --git a/Telegram/SourceFiles/history/history_message.h b/Telegram/SourceFiles/history/history_message.h index 32290ad54..8112b0465 100644 --- a/Telegram/SourceFiles/history/history_message.h +++ b/Telegram/SourceFiles/history/history_message.h @@ -170,6 +170,7 @@ public: [[nodiscard]] int viewsCount() const override; [[nodiscard]] int repliesCount() const override; [[nodiscard]] bool repliesAreComments() const override; + [[nodiscard]] bool externalReply() const override; [[nodiscard]] FullMsgId commentsItemId() const override; void setCommentsItemId(FullMsgId id) override; bool updateDependencyItem() override; diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 1292e4a98..1aae159e3 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -577,7 +577,7 @@ void Message::paintCommentsButton( Painter &p, QRect &g, bool selected) const { - if (!data()->repliesAreComments()) { + if (!data()->repliesAreComments() && !data()->externalReply()) { return; } if (!_comments) { @@ -586,7 +586,6 @@ void Message::paintCommentsButton( } const auto outbg = hasOutLayout(); const auto views = data()->Get(); - Assert(views != nullptr); g.setHeight(g.height() - st::historyCommentsButtonHeight); const auto top = g.top() + g.height(); @@ -614,7 +613,7 @@ void Message::paintCommentsButton( top + (st::historyCommentsButtonHeight - open.height()) / 2, width); - if (views->recentRepliers.empty()) { + if (!views || views->recentRepliers.empty()) { const auto &icon = outbg ? (selected ? st::historyCommentsOutSelected : st::historyCommentsOut) : (selected ? st::historyCommentsInSelected : st::historyCommentsIn); @@ -700,8 +699,8 @@ void Message::paintCommentsButton( left, top + (st::historyCommentsButtonHeight - st::semiboldFont->height) / 2, width, - views->replies.text, - views->replies.textWidth); + views ? views->replies.text : tr::lng_replies_view_original(tr::now), + views ? views->replies.textWidth : -1); } void Message::paintFromName( @@ -919,7 +918,7 @@ PointState Message::pointState(QPoint point) const { auto mediaOnBottom = (mediaDisplayed && media->isBubbleBottom()) || (entry/* && entry->isBubbleBottom()*/); auto mediaOnTop = (mediaDisplayed && media->isBubbleTop()) || (entry && entry->isBubbleTop()); - if (item->repliesAreComments()) { + if (item->repliesAreComments() || item->externalReply()) { g.setHeight(g.height() - st::historyCommentsButtonHeight); } @@ -1199,7 +1198,7 @@ bool Message::getStateCommentsButton( st::historyCommentsButtonHeight).contains(point)) { return false; } - if (!_comments->link) { + if (!_comments->link && data()->repliesAreComments()) { const auto fullId = data()->fullId(); _comments->link = std::make_shared([=] { if (const auto window = App::wnd()) { @@ -1210,6 +1209,8 @@ bool Message::getStateCommentsButton( } } }); + } else if (!_comments->link && data()->externalReply()) { + _comments->link = rightActionLink(); } outResult->link = _comments->link; _comments->lastPoint = point - QPoint(g.left(), g.top() + g.height()); @@ -1958,7 +1959,9 @@ bool Message::displayFastShare() const { bool Message::displayGoToOriginal() const { const auto item = message(); if (const auto forwarded = item->Get()) { - return forwarded->savedFromPeer && forwarded->savedFromMsgId; + return forwarded->savedFromPeer + && forwarded->savedFromMsgId + && (!item->externalReply() || !hasBubble()); } return false; } @@ -2276,7 +2279,7 @@ int Message::resizeContentGetHeight(int newWidth) { newHeight += st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom(); } - if (item->repliesAreComments()) { + if (item->repliesAreComments() || item->externalReply()) { newHeight += st::historyCommentsButtonHeight; } } else if (mediaDisplayed) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index c2e977e20..56ba7c87f 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -1137,6 +1137,7 @@ bool Gif::needsBubble() const { } const auto item = _parent->data(); return item->repliesAreComments() + || item->externalReply() || item->viaBot() || _parent->displayedReply() || _parent->displayForwardedFrom() diff --git a/Telegram/SourceFiles/history/view/media/history_view_location.cpp b/Telegram/SourceFiles/history/view/media/history_view_location.cpp index 4824dd6fc..6287715d7 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_location.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_location.cpp @@ -320,6 +320,7 @@ bool Location::needsBubble() const { } const auto item = _parent->data(); return item->repliesAreComments() + || item->externalReply() || item->viaBot() || _parent->displayedReply() || _parent->displayForwardedFrom() diff --git a/Telegram/SourceFiles/history/view/media/history_view_media.cpp b/Telegram/SourceFiles/history/view/media/history_view_media.cpp index 30c26b9e0..7f4f47b2a 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media.cpp @@ -187,7 +187,9 @@ TextState Media::getStateGrouped( } bool Media::isRoundedInBubbleBottom() const { - return isBubbleBottom() && !_parent->data()->repliesAreComments(); + return isBubbleBottom() + && !_parent->data()->repliesAreComments() + && !_parent->data()->externalReply(); } } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp index ed3e0688a..9ddf83212 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp @@ -454,6 +454,7 @@ bool GroupedMedia::computeNeedBubble() const { } if (const auto item = _parent->data()) { if (item->repliesAreComments() + || item->externalReply() || item->viaBot() || _parent->displayedReply() || _parent->displayForwardedFrom() diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp index d0c63e583..b23faf990 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp @@ -802,6 +802,7 @@ bool Photo::needsBubble() const { const auto item = _parent->data(); if (item->toHistoryMessage()) { return item->repliesAreComments() + || item->externalReply() || item->viaBot() || _parent->displayedReply() || _parent->displayForwardedFrom()