Fix refreshing bottom info.

This commit is contained in:
John Preston 2021-12-03 18:56:48 +04:00
parent 1af2cfe143
commit 2b0cd2a611
4 changed files with 11 additions and 4 deletions

View File

@ -1900,6 +1900,7 @@ void HistoryMessage::changeRepliesCount(
}
}
refreshRepliesText(views);
history()->owner().notifyItemDataChange(this);
}
void HistoryMessage::setUnreadRepliesCount(

View File

@ -23,11 +23,11 @@ BottomInfo::BottomInfo(Data &&data) : _data(std::move(data)) {
layout();
}
void BottomInfo::update(Data &&data) {
void BottomInfo::update(Data &&data, int availableWidth) {
_data = std::move(data);
layout();
if (!_size.isEmpty()) {
resizeToWidth(_size.width());
resizeToWidth(std::min(optimalSize().width(), availableWidth));
}
}
@ -165,6 +165,7 @@ int BottomInfo::resizeToWidth(int newWidth) {
void BottomInfo::layout() {
layoutDateText();
layoutViewsText();
layoutRepliesText();
layoutReactionsText();
countOptimalSize();
}
@ -252,6 +253,11 @@ void BottomInfo::countOptimalSize() {
+ _views.maxWidth()
+ st::historyViewsWidth;
}
if (!_replies.isEmpty()) {
width += st::historyViewsSpace
+ _replies.maxWidth()
+ st::historyViewsWidth;
}
if (!_reactions.isEmpty()) {
width += st::historyReactionsSkip + _reactions.maxWidth();
}

View File

@ -42,7 +42,7 @@ public:
};
explicit BottomInfo(Data &&data);
void update(Data &&data);
void update(Data &&data, int availableWidth);
[[nodiscard]] QSize optimalSize() const;
[[nodiscard]] QSize size() const;

View File

@ -1808,7 +1808,7 @@ bool Message::isSignedAuthorElided() const {
void Message::itemDataChanged() {
const auto was = _bottomInfo.size();
_bottomInfo.update(BottomInfoDataFromMessage(this));
_bottomInfo.update(BottomInfoDataFromMessage(this), width());
if (was != _bottomInfo.size()) {
history()->owner().requestViewResize(this);
} else {