mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-23 00:36:53 +00:00
Add go to original button to Replies chat.
This commit is contained in:
parent
008a301755
commit
3a51303fb0
@ -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";
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<HistoryMessageForwarded>()) {
|
||||
return forwarded->savedFromPeer && forwarded->savedFromMsgId;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
FullMsgId HistoryMessage::commentsItemId() const {
|
||||
if (const auto views = Get<HistoryMessageViews>()) {
|
||||
return FullMsgId(views->commentsChannelId, views->commentsRootId);
|
||||
|
@ -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;
|
||||
|
@ -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<HistoryMessageViews>();
|
||||
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<LambdaClickHandler>([=] {
|
||||
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<HistoryMessageForwarded>()) {
|
||||
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) {
|
||||
|
@ -1137,6 +1137,7 @@ bool Gif::needsBubble() const {
|
||||
}
|
||||
const auto item = _parent->data();
|
||||
return item->repliesAreComments()
|
||||
|| item->externalReply()
|
||||
|| item->viaBot()
|
||||
|| _parent->displayedReply()
|
||||
|| _parent->displayForwardedFrom()
|
||||
|
@ -320,6 +320,7 @@ bool Location::needsBubble() const {
|
||||
}
|
||||
const auto item = _parent->data();
|
||||
return item->repliesAreComments()
|
||||
|| item->externalReply()
|
||||
|| item->viaBot()
|
||||
|| _parent->displayedReply()
|
||||
|| _parent->displayForwardedFrom()
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user