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)); id));
} }
if (changed) { if (changed) {
history()->owner().requestItemResize(this); history()->owner().notifyItemDataChange(this);
} }
} }

View file

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

View file

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

View file

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

View file

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