From e9dffe78e3da4d2811e207788f297f715e7d840f Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 11 Sep 2020 21:55:22 +0300 Subject: [PATCH] Fix minimal width of message bubble with comments. --- Telegram/SourceFiles/data/data_peer.cpp | 9 +++++- .../history/view/history_view_message.cpp | 31 ++++++++++++++++--- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index c97cf6f94..68e73d520 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -751,7 +751,14 @@ bool PeerData::isBroadcast() const { } bool PeerData::isRepliesChat() const { - return (id == peerFromUser(708513)); + constexpr auto kProductionId = peerFromUser(1271266957); + constexpr auto kTestId = peerFromUser(708513); + if (id != kTestId && id != kProductionId) { + return false; + } + return ((session().mtp().environment() == MTP::Environment::Production) + ? kProductionId + : kTestId) == id; } bool PeerData::canWrite() const { diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 1aae159e3..0410ca212 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -255,10 +255,11 @@ QSize Message::performCountOptimalSize() { } if (drawBubble()) { - auto forwarded = item->Get(); - auto reply = displayedReply(); - auto via = item->Get(); - auto entry = logEntryOriginal(); + const auto forwarded = item->Get(); + const auto reply = displayedReply(); + const auto via = item->Get(); + const auto entry = logEntryOriginal(); + const auto views = item->Get(); if (forwarded) { forwarded->create(via); } @@ -362,6 +363,28 @@ QSize Message::performCountOptimalSize() { minHeight += entry->minHeight(); } } + if (item->repliesAreComments() && !views->replies.text.isEmpty()) { + const auto limit = HistoryMessageViews::kMaxRecentRepliers; + const auto single = st::historyCommentsUserpicSize; + const auto shift = st::historyCommentsUserpicOverlap; + const auto added = single + + (limit - 1) * (single - shift) + + st::historyCommentsSkipLeft + + st::historyCommentsSkipRight + + st::historyCommentsSkipText + + st::historyCommentsOpenOutSelected.width() + + st::historyCommentsSkipRight; + accumulate_max(maxWidth, added + views->replies.textWidth); + } else if (item->externalReply()) { + const auto added = st::historyCommentsIn.width() + + st::historyCommentsSkipLeft + + st::historyCommentsSkipRight + + st::historyCommentsSkipText + + st::historyCommentsOpenOutSelected.width() + + st::historyCommentsSkipRight; + accumulate_max(maxWidth, added + st::semiboldFont->width( + tr::lng_replies_view_original(tr::now))); + } } else if (media) { media->initDimensions(); maxWidth = media->maxWidth();