diff --git a/Telegram/Resources/icons/dialogs/dialogs_pinned_shadow.png b/Telegram/Resources/icons/dialogs/dialogs_pinned_shadow.png new file mode 100644 index 0000000000..19f8e0b158 Binary files /dev/null and b/Telegram/Resources/icons/dialogs/dialogs_pinned_shadow.png differ diff --git a/Telegram/Resources/icons/dialogs/dialogs_pinned_shadow@2x.png b/Telegram/Resources/icons/dialogs/dialogs_pinned_shadow@2x.png new file mode 100644 index 0000000000..ac695b71d3 Binary files /dev/null and b/Telegram/Resources/icons/dialogs/dialogs_pinned_shadow@2x.png differ diff --git a/Telegram/Resources/icons/dialogs/dialogs_pinned_shadow@3x.png b/Telegram/Resources/icons/dialogs/dialogs_pinned_shadow@3x.png new file mode 100644 index 0000000000..b05f0f35f9 Binary files /dev/null and b/Telegram/Resources/icons/dialogs/dialogs_pinned_shadow@3x.png differ diff --git a/Telegram/SourceFiles/data/data_story.cpp b/Telegram/SourceFiles/data/data_story.cpp index d191d2360c..9db62b958b 100644 --- a/Telegram/SourceFiles/data/data_story.cpp +++ b/Telegram/SourceFiles/data/data_story.cpp @@ -390,7 +390,12 @@ TextWithEntities Story::inReplyText() const { } void Story::setPinnedToTop(bool pinned) { - _pinnedToTop = pinned; + if (_pinnedToTop != pinned) { + _pinnedToTop = pinned; + if (const auto item = _peer->owner().stories().lookupItem(this)) { + item->setIsPinned(pinned); + } + } } bool Story::pinnedToTop() const { diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 3dd4f26bb0..12727f64f4 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -1360,6 +1360,10 @@ void HistoryItem::setIsPinned(bool pinned) { const auto changed = (isPinned() != pinned); if (pinned) { _flags |= MessageFlag::Pinned; + if (_flags & MessageFlag::StoryItem) { + return; + } + auto &storage = _history->session().storage(); storage.add(Storage::SharedMediaAddExisting( _history->peer->id, @@ -1379,6 +1383,10 @@ void HistoryItem::setIsPinned(bool pinned) { } } else { _flags &= ~MessageFlag::Pinned; + if (_flags & MessageFlag::StoryItem) { + return; + } + _history->session().storage().remove(Storage::SharedMediaRemoveOne( _history->peer->id, Storage::SharedMediaType::Pinned, @@ -1687,6 +1695,11 @@ void HistoryItem::setStoryFields(not_null story) { /*ttlSeconds = */0); } setText(story->caption()); + if (story->pinnedToTop()) { + _flags |= MessageFlag::Pinned; + } else { + _flags &= ~MessageFlag::Pinned; + } } void HistoryItem::applyEdition(const MTPDmessageService &message) { diff --git a/Telegram/SourceFiles/info/stories/info_stories_provider.cpp b/Telegram/SourceFiles/info/stories/info_stories_provider.cpp index c3025bf854..6c9a7dabb3 100644 --- a/Telegram/SourceFiles/info/stories/info_stories_provider.cpp +++ b/Telegram/SourceFiles/info/stories/info_stories_provider.cpp @@ -343,7 +343,10 @@ std::unique_ptr Provider::createLayout( return nullptr; }; using namespace Overview::Layout; - const auto options = MediaOptions{ .story = true }; + const auto options = MediaOptions{ + .pinned = item->isPinned(), + .story = true, + }; if (const auto photo = getPhoto()) { return std::make_unique(delegate, item, photo, options); } else if (const auto file = getFile()) { diff --git a/Telegram/SourceFiles/overview/overview.style b/Telegram/SourceFiles/overview/overview.style index 82a9c70e6f..6910d536ba 100644 --- a/Telegram/SourceFiles/overview/overview.style +++ b/Telegram/SourceFiles/overview/overview.style @@ -140,3 +140,12 @@ overviewVideoPlaySelected: icon {{ "overview_video_play", historyFileThumbIconFg overviewVideoDownload: icon {{ "overview_video_download", historyFileThumbIconFg }}; overviewVideoDownloadSelected: icon {{ "overview_video_download", historyFileThumbIconFgSelected }}; overviewVideoRadialSize: 36px; + +storyPinnedIcon: icon{ + { "dialogs/dialogs_pinned_shadow", windowShadowFg }, + { "dialogs/dialogs_pinned", historyFileThumbIconFg } +}; +storyPinnedIconSelected: icon{ + { "dialogs/dialogs_pinned_shadow", windowShadowFg }, + { "dialogs/dialogs_pinned", historyFileThumbIconFgSelected } +}; diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index b742a6436c..e38bd1e239 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -339,6 +339,7 @@ Photo::Photo( , _spoiler(options.spoiler ? std::make_unique([=] { delegate->repaintItem(this); }) : nullptr) +, _pinned(options.pinned) , _story(options.story) { if (_data->inlineThumbnailBytes().isEmpty() && (_data->hasExact(Data::PhotoSize::Small) @@ -407,6 +408,14 @@ void Photo::paint(Painter &p, const QRect &clip, TextSelection selection, const if (selected) { p.fillRect(0, 0, _width, _height, st::overviewPhotoSelectOverlay); } + + if (_pinned) { + const auto &icon = selected + ? st::storyPinnedIconSelected + : st::storyPinnedIcon; + icon.paint(p, _width - icon.width(), 0, _width); + } + const auto checkDelta = st::overviewCheckSkip + st::overviewCheck.size; const auto checkLeft = _width - checkDelta; const auto checkTop = _height - checkDelta; @@ -475,6 +484,7 @@ Video::Video( , _spoiler(options.spoiler ? std::make_unique([=] { delegate->repaintItem(this); }) : nullptr) +, _pinned(options.pinned) , _story(options.story) { setDocumentLinks(_data); _data->loadThumbnail(parent->fullId()); @@ -547,6 +557,13 @@ void Video::paint(Painter &p, const QRect &clip, TextSelection selection, const p.fillRect(QRect(0, 0, _width, _height), st::overviewPhotoSelectOverlay); } + if (_pinned) { + const auto &icon = selected + ? st::storyPinnedIconSelected + : st::storyPinnedIcon; + icon.paint(p, _width - icon.width(), 0, _width); + } + if (!selected && !context->selecting && radialOpacity < 1.) { if (clip.intersects(QRect(0, _height - st::normalFont->height, _width, st::normalFont->height))) { const auto download = !loaded && !_dataMedia->canBePlayed(parent()); diff --git a/Telegram/SourceFiles/overview/overview_layout.h b/Telegram/SourceFiles/overview/overview_layout.h index 331d7f3e29..051dbb22e6 100644 --- a/Telegram/SourceFiles/overview/overview_layout.h +++ b/Telegram/SourceFiles/overview/overview_layout.h @@ -185,6 +185,7 @@ struct Info : public RuntimeComponent { struct MediaOptions { bool spoiler = false; + bool pinned = false; bool story = false; }; @@ -218,6 +219,7 @@ private: QPixmap _pix; bool _goodLoaded = false; + bool _pinned = false; bool _story = false; }; @@ -318,6 +320,7 @@ private: QPixmap _pix; bool _pixBlurred = true; + bool _pinned = false; bool _story = false; };