Fix timestamp text appearing glitch.

This commit is contained in:
John Preston
2026-04-10 21:22:40 +07:00
parent f4cbbb251f
commit 045cb6822f
2 changed files with 26 additions and 5 deletions
@@ -3996,7 +3996,7 @@ TextState Message::bottomInfoTextState(
}
int Message::infoWidth() const {
return _bottomInfo.optimalSize().width();
return _bottomInfo.maxWidth();
}
int Message::bottomInfoFirstLineWidth() const {
@@ -5311,10 +5311,11 @@ bool Message::textAppearCheckLine(not_null<TextAppearing*> appearing) {
textAppearStartWidthAnimation(appearing);
}
}
if (appearing->targetHeight != line->bottom) {
if (!shown || appearing->shownHeight >= line->bottom) {
const auto targetHeight = textAppearTargetHeight(appearing);
if (appearing->targetHeight != targetHeight) {
if (!shown || appearing->shownHeight >= targetHeight) {
appearing->heightAnimation.stop();
appearing->shownHeight = appearing->targetHeight = line->bottom;
appearing->shownHeight = appearing->targetHeight = targetHeight;
} else {
const auto widthStart = appearing->startLineWidth;
const auto widthTarget = appearing->targetLineWidth;
@@ -5370,7 +5371,7 @@ void Message::textAppearStartHeightAnimation(
const auto from = appearing->shownHeight;
const auto to
= appearing->targetHeight
= appearing->lines[appearing->shownLine].bottom;
= textAppearTargetHeight(appearing);
const auto duration = appearing->finalizing
? kLineHeightAppearFinalDuration
: kLineHeightAppearDuration;
@@ -5379,6 +5380,24 @@ void Message::textAppearStartHeightAnimation(
}, from, to, duration, anim::easeOutCubic);
}
int Message::textAppearTargetHeight(
not_null<TextAppearing*> appearing) const {
const auto shown = appearing->shownLine;
const auto lines = int(appearing->lines.size());
if (shown + 1 >= lines) {
return appearing->lines.back().bottom;
}
const auto bottom = appearing->lines[shown].bottom;
const auto nextWidth = appearing->lines[shown + 1].width;
const auto available = std::max(
appearing->lines[shown].width,
appearing->shownWidth);
if (nextWidth + skipBlockWidth() <= available) {
return bottom;
}
return bottom + skipBlockHeight();
}
void Message::textAppearWidthCallback() {
const auto appearing = Get<TextAppearing>();
const auto now = int(base::SafeRound(
@@ -397,6 +397,8 @@ private:
void textAppearStartHeightAnimation(not_null<TextAppearing*> appearing);
void textAppearWidthCallback();
void textAppearHeightCallback();
[[nodiscard]] int textAppearTargetHeight(
not_null<TextAppearing*> appearing) const;
void refreshRightBadge();
[[nodiscard]] int rightBadgeWidth() const;