From 9df229a230b58f12032d79680330bf810082b8ed Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 3 Jan 2022 18:14:45 +0300 Subject: [PATCH] Add pinned message icon. Regression was introduced in 1af2cfe143. Fixes #17489. --- Telegram/SourceFiles/history/history_item.cpp | 2 +- .../history/view/history_view_bottom_info.cpp | 17 +++++++++++++++++ .../history/view/history_view_bottom_info.h | 1 + .../history/view/history_view_message.cpp | 4 ---- .../history/view/history_view_message.h | 1 - 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 31e866ffa..c2dd5b6e7 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -382,7 +382,7 @@ void HistoryItem::setIsPinned(bool pinned) { id)); } if (changed) { - history()->owner().requestItemResize(this); + history()->owner().notifyItemDataChange(this); } } diff --git a/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp b/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp index de6d99397..1e5fc9c9a 100644 --- a/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp +++ b/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp @@ -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) { if (item->isSponsored()) { result.flags |= Flag::Sponsored; } + if (item->isPinned() && message->context() != Context::Pinned) { + result.flags |= Flag::Pinned; + } if (const auto msgsigned = item->Get()) { if (!msgsigned->isAnonymousRank) { result.author = msgsigned->author; diff --git a/Telegram/SourceFiles/history/view/history_view_bottom_info.h b/Telegram/SourceFiles/history/view/history_view_bottom_info.h index 71b37c182..a44b035d0 100644 --- a/Telegram/SourceFiles/history/view/history_view_bottom_info.h +++ b/Telegram/SourceFiles/history/view/history_view_bottom_info.h @@ -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; }; diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index d9dfc4b48..3ed7fd0ed 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -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: diff --git a/Telegram/SourceFiles/history/view/history_view_message.h b/Telegram/SourceFiles/history/view/history_view_message.h index 5ec7a1c27..2d3ae6159 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.h +++ b/Telegram/SourceFiles/history/view/history_view_message.h @@ -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;