diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 12727f64f..a6effce00 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -1358,6 +1358,11 @@ bool HistoryItem::markContentsRead(bool fromThisClient) { void HistoryItem::setIsPinned(bool pinned) { const auto changed = (isPinned() != pinned); + const auto guard = gsl::finally([&] { + if (changed) { + _history->owner().notifyItemDataChange(this); + } + }); if (pinned) { _flags |= MessageFlag::Pinned; if (_flags & MessageFlag::StoryItem) { @@ -1392,9 +1397,6 @@ void HistoryItem::setIsPinned(bool pinned) { Storage::SharedMediaType::Pinned, id)); } - if (changed) { - _history->owner().notifyItemDataChange(this); - } } void HistoryItem::returnSavedMedia() { diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp index 8e9006629..280b35589 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp @@ -233,6 +233,13 @@ void ListWidget::subscribeToSession( ) | rpl::start_with_next([this](auto item) { repaintItem(item); }, lifetime); + + session->data().itemDataChanges( + ) | rpl::start_with_next([=](not_null item) { + if (const auto found = findItemByItem(item)) { + found->layout->itemDataChanged(); + } + }, lifetime); } void ListWidget::setupSelectRestriction() { diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index e38bd1e23..e75af1464 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -460,6 +460,14 @@ void Photo::clearSpoiler() { } } +void Photo::itemDataChanged() { + const auto pinned = parent()->isPinned(); + if (_pinned != pinned) { + _pinned = pinned; + delegate()->repaintItem(this); + } +} + void Photo::clearHeavyPart() { _dataMedia = nullptr; } @@ -637,6 +645,14 @@ void Video::clearSpoiler() { } } +void Video::itemDataChanged() { + const auto pinned = parent()->isPinned(); + if (_pinned != pinned) { + _pinned = pinned; + delegate()->repaintItem(this); + } +} + void Video::clearHeavyPart() { _dataMedia = nullptr; } diff --git a/Telegram/SourceFiles/overview/overview_layout.h b/Telegram/SourceFiles/overview/overview_layout.h index 051dbb22e..3526b5e57 100644 --- a/Telegram/SourceFiles/overview/overview_layout.h +++ b/Telegram/SourceFiles/overview/overview_layout.h @@ -71,6 +71,8 @@ public: void invalidateCache(); + virtual void itemDataChanged() { + } virtual void clearHeavyPart() { } @@ -205,6 +207,7 @@ public: QPoint point, StateRequest request) const override; + void itemDataChanged() override; void clearHeavyPart() override; private: @@ -298,6 +301,7 @@ public: QPoint point, StateRequest request) const override; + void itemDataChanged() override; void clearHeavyPart() override; void clearSpoiler() override;