Add pinned message icon.

Regression was introduced in 1af2cfe143.

Fixes #17489.
This commit is contained in:
John Preston 2022-01-03 18:14:45 +03:00
parent a1c342c822
commit 9df229a230
5 changed files with 19 additions and 6 deletions

View File

@ -382,7 +382,7 @@ void HistoryItem::setIsPinned(bool pinned) {
id));
}
if (changed) {
history()->owner().requestItemResize(this);
history()->owner().notifyItemDataChange(this);
}
}

View File

@ -159,6 +159,17 @@ void BottomInfo::paint(
authorEditedWidth,
outerWidth);
if (_data.flags & Data::Flag::Pinned) {
const auto &icon = inverted
? st->historyPinInvertedIcon()
: stm->historyPinIcon;
right -= st::historyPinWidth;
icon.paint(
p,
right,
firstLineBottom + st::historyPinTop,
outerWidth);
}
if (!_views.isEmpty()) {
const auto viewsWidth = _views.maxWidth();
right -= st::historyViewsSpace + viewsWidth;
@ -367,6 +378,9 @@ QSize BottomInfo::countOptimalSize() {
+ _replies.maxWidth()
+ st::historyViewsWidth;
}
if (_data.flags & Data::Flag::Pinned) {
width += st::historyPinWidth;
}
_reactionsMaxWidth = countReactionsMaxWidth();
width += _reactionsMaxWidth;
return QSize(width, st::msgDateFont->height);
@ -410,6 +424,9 @@ BottomInfo::Data BottomInfoDataFromMessage(not_null<Message*> message) {
if (item->isSponsored()) {
result.flags |= Flag::Sponsored;
}
if (item->isPinned() && message->context() != Context::Pinned) {
result.flags |= Flag::Pinned;
}
if (const auto msgsigned = item->Get<HistoryMessageSigned>()) {
if (!msgsigned->isAnonymousRank) {
result.author = msgsigned->author;

View File

@ -35,6 +35,7 @@ public:
Sending = 0x04,
RepliesContext = 0x08,
Sponsored = 0x10,
Pinned = 0x20,
//Unread, // We don't want to pass and update it in Date for now.
};
friend inline constexpr bool is_flag_type(Flag) { return true; };

View File

@ -2148,10 +2148,6 @@ bool Message::toggleSelectionByHandlerClick(
return false;
}
bool Message::displayPinIcon() const {
return data()->isPinned() && !isPinnedContext();
}
bool Message::hasFromName() const {
switch (context()) {
case Context::AdminLog:

View File

@ -221,7 +221,6 @@ private:
[[nodiscard]] bool displayFastShare() const;
[[nodiscard]] bool displayGoToOriginal() const;
[[nodiscard]] ClickHandlerPtr fastReplyLink() const;
[[nodiscard]] bool displayPinIcon() const;
void refreshInfoSkipBlock();
[[nodiscard]] int plainMaxWidth() const;