Fix minimal width of message bubble with comments.

This commit is contained in:
John Preston 2020-09-11 21:55:22 +03:00
parent 3a51303fb0
commit e9dffe78e3
2 changed files with 35 additions and 5 deletions

View file

@ -751,7 +751,14 @@ bool PeerData::isBroadcast() const {
} }
bool PeerData::isRepliesChat() 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 { bool PeerData::canWrite() const {

View file

@ -255,10 +255,11 @@ QSize Message::performCountOptimalSize() {
} }
if (drawBubble()) { if (drawBubble()) {
auto forwarded = item->Get<HistoryMessageForwarded>(); const auto forwarded = item->Get<HistoryMessageForwarded>();
auto reply = displayedReply(); const auto reply = displayedReply();
auto via = item->Get<HistoryMessageVia>(); const auto via = item->Get<HistoryMessageVia>();
auto entry = logEntryOriginal(); const auto entry = logEntryOriginal();
const auto views = item->Get<HistoryMessageViews>();
if (forwarded) { if (forwarded) {
forwarded->create(via); forwarded->create(via);
} }
@ -362,6 +363,28 @@ QSize Message::performCountOptimalSize() {
minHeight += entry->minHeight(); 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) { } else if (media) {
media->initDimensions(); media->initDimensions();
maxWidth = media->maxWidth(); maxWidth = media->maxWidth();