Version 4.3: Fix rounding with inline keyboard markup.

This commit is contained in:
John Preston 2022-11-05 19:07:20 +04:00
parent efc06b7951
commit 29e30d2d00
2 changed files with 20 additions and 13 deletions

View file

@ -485,13 +485,15 @@ auto Message::takeReactionAnimations()
}
QSize Message::performCountOptimalSize() {
const auto item = message();
const auto markup = item->inlineReplyMarkup();
validateText();
validateInlineKeyboard(markup);
updateViewButtonExistence();
updateMediaInBubbleState();
refreshRightBadge();
refreshInfoSkipBlock();
const auto item = message();
const auto media = this->media();
auto maxWidth = 0;
@ -642,18 +644,10 @@ QSize Message::performCountOptimalSize() {
maxWidth = st::msgMinWidth;
minHeight = 0;
}
if (const auto markup = item->inlineReplyMarkup()) {
if (!markup->inlineKeyboard && !markup->hiddenBy(item->media())) {
markup->inlineKeyboard = std::make_unique<ReplyKeyboard>(
item,
std::make_unique<KeyboardStyle>(st::msgBotKbButton));
}
// if we have a text bubble we can resize it to fit the keyboard
// but if we have only media we don't do that
if (hasVisibleText() && markup->inlineKeyboard) {
accumulate_max(maxWidth, markup->inlineKeyboard->naturalWidth());
}
// if we have a text bubble we can resize it to fit the keyboard
// but if we have only media we don't do that
if (markup && markup->inlineKeyboard && hasVisibleText()) {
accumulate_max(maxWidth, markup->inlineKeyboard->naturalWidth());
}
return QSize(maxWidth, minHeight);
}
@ -2414,6 +2408,17 @@ void Message::refreshReactions() {
}
}
void Message::validateInlineKeyboard(HistoryMessageReplyMarkup *markup) {
if (!markup
|| markup->inlineKeyboard
|| markup->hiddenBy(data()->media())) {
return;
}
markup->inlineKeyboard = std::make_unique<ReplyKeyboard>(
data(),
std::make_unique<KeyboardStyle>(st::msgBotKbButton));
}
void Message::validateFromNameText(PeerData *from) const {
if (!from) {
if (_fromNameStatus) {

View file

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
class HistoryMessage;
struct HistoryMessageEdited;
struct HistoryMessageForwarded;
struct HistoryMessageReplyMarkup;
namespace Data {
struct ReactionId;
@ -256,6 +257,7 @@ private:
[[nodiscard]] int plainMaxWidth() const;
[[nodiscard]] int monospaceMaxWidth() const;
void validateInlineKeyboard(HistoryMessageReplyMarkup *markup);
void updateViewButtonExistence();
[[nodiscard]] int viewButtonHeight() const;