diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 85c4b7917..582a695fe 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -741,7 +741,8 @@ void ExportTestChatTheme( MTP_int(color(bg.size() > 2 ? bg[2] : Qt::black)), MTP_int(color(bg.size() > 3 ? bg[3] : Qt::black)), MTP_int(fields.paper->patternIntensity()), - MTP_int(0))); + MTP_int(0), // rotation + MTPstring())); // emoticon }; const auto light = inputSettings(Data::CloudThemeType::Light); if (!light) { diff --git a/Telegram/SourceFiles/data/data_story.cpp b/Telegram/SourceFiles/data/data_story.cpp index e1d0c87c9..7631892a3 100644 --- a/Telegram/SourceFiles/data/data_story.cpp +++ b/Telegram/SourceFiles/data/data_story.cpp @@ -633,6 +633,10 @@ const std::vector &Story::suggestedReactions() const { return _suggestedReactions; } +const std::vector &Story::channelPosts() const { + return _channelPosts; +} + void Story::applyChanges( StoryMedia media, const MTPDstoryItem &data, @@ -735,9 +739,8 @@ void Story::applyFields( } auto locations = std::vector(); auto suggestedReactions = std::vector(); + auto channelPosts = std::vector(); if (const auto areas = data.vmedia_areas()) { - locations.reserve(areas->v.size()); - suggestedReactions.reserve(areas->v.size()); for (const auto &area : areas->v) { if (const auto location = ParseLocation(area)) { locations.push_back(*location); @@ -748,6 +751,8 @@ void Story::applyFields( reaction->count = i->second; } suggestedReactions.push_back(*reaction); + } else if (auto post = ParseChannelPost(area)) { + channelPosts.push_back(*post); } } } @@ -759,6 +764,7 @@ void Story::applyFields( const auto locationsChanged = (_locations != locations); const auto suggestedReactionsChanged = (_suggestedReactions != suggestedReactions); + const auto channelPostsChanged = (_channelPosts != channelPosts); const auto reactionChanged = (_sentReactionId != reaction); _out = out; @@ -781,6 +787,9 @@ void Story::applyFields( if (suggestedReactionsChanged) { _suggestedReactions = std::move(suggestedReactions); } + if (channelPostsChanged) { + _channelPosts = std::move(channelPosts); + } if (reactionChanged) { _sentReactionId = reaction; } @@ -789,7 +798,8 @@ void Story::applyFields( const auto changed = editedChanged || captionChanged || mediaChanged - || locationsChanged; + || locationsChanged + || channelPostsChanged; const auto reactionsChanged = reactionChanged || suggestedReactionsChanged; if (!initial && (changed || reactionsChanged)) { diff --git a/Telegram/SourceFiles/data/data_story.h b/Telegram/SourceFiles/data/data_story.h index e953212bc..4fb4796b2 100644 --- a/Telegram/SourceFiles/data/data_story.h +++ b/Telegram/SourceFiles/data/data_story.h @@ -192,6 +192,8 @@ public: [[nodiscard]] const std::vector &locations() const; [[nodiscard]] auto suggestedReactions() const -> const std::vector &; + [[nodiscard]] auto channelPosts() const + -> const std::vector &; void applyChanges( StoryMedia media, @@ -238,6 +240,7 @@ private: std::vector> _recentViewers; std::vector _locations; std::vector _suggestedReactions; + std::vector _channelPosts; StoryViews _views; StoryViews _channelReactions; const TimeId _date = 0; diff --git a/Telegram/SourceFiles/data/data_wall_paper.cpp b/Telegram/SourceFiles/data/data_wall_paper.cpp index f8532a158..3f97d1e29 100644 --- a/Telegram/SourceFiles/data/data_wall_paper.cpp +++ b/Telegram/SourceFiles/data/data_wall_paper.cpp @@ -371,7 +371,8 @@ MTPWallPaperSettings WallPaper::mtpSettings() const { serializeForIndex(2), serializeForIndex(3), MTP_int(_intensity), - MTP_int(_rotation)); + MTP_int(_rotation), + MTPstring()); // emoticon } WallPaper WallPaper::withUrlParams( diff --git a/Telegram/SourceFiles/media/stories/media_stories_controller.cpp b/Telegram/SourceFiles/media/stories/media_stories_controller.cpp index 07605c365..d6d735043 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_controller.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_controller.cpp @@ -119,6 +119,25 @@ struct SameDayRange { int(base::SafeRound(asin * point.x() + acos * point.y()))); } +[[nodiscard]] ClickHandlerPtr MakeChannelPostHandler( + not_null session, + FullMsgId item) { + return std::make_shared(crl::guard(session, [=] { + const auto peer = session->data().peer(item.peer); + if (const auto window = Core::App().windowFor(peer)) { + if (const auto controller = window->sessionController()) { + if (&controller->session() == &peer->session()) { + Core::App().hideMediaView(); + controller->showPeerHistory( + item.peer, + Window::SectionShow::Way::ClearStack, + item.msg); + } + } + } + })); +} + } // namespace class Controller::PhotoPlayback final { @@ -1024,10 +1043,17 @@ void Controller::updateAreas(Data::Story *story) { const auto &suggestedReactions = story ? story->suggestedReactions() : std::vector(); + const auto &channelPosts = story + ? story->channelPosts() + : std::vector(); if (_locations != locations) { _locations = locations; _areas.clear(); } + if (_channelPosts != channelPosts) { + _channelPosts = channelPosts; + _areas.clear(); + } const auto reactionsCount = int(suggestedReactions.size()); if (_suggestedReactions.size() == reactionsCount && !_areas.empty()) { for (auto i = 0; i != reactionsCount; ++i) { @@ -1046,10 +1072,6 @@ void Controller::updateAreas(Data::Story *story) { _suggestedReactions = suggestedReactions; _areas.clear(); } - if (_areas.empty() || _suggestedReactions.empty()) { - return; - } - } PauseState Controller::pauseState() const { @@ -1172,10 +1194,16 @@ void Controller::updatePlayback(const Player::TrackState &state) { ClickHandlerPtr Controller::lookupAreaHandler(QPoint point) const { const auto &layout = _layout.current(); - if ((_locations.empty() && _suggestedReactions.empty()) || !layout) { + if (!layout + || (_locations.empty() + && _suggestedReactions.empty() + && _channelPosts.empty())) { return nullptr; } else if (_areas.empty()) { - _areas.reserve(_locations.size() + _suggestedReactions.size()); + const auto now = story(); + _areas.reserve(_locations.size() + + _suggestedReactions.size() + + _channelPosts.size()); for (const auto &location : _locations) { _areas.push_back({ .original = location.area.geometry, @@ -1205,6 +1233,17 @@ ClickHandlerPtr Controller::lookupAreaHandler(QPoint point) const { .reaction = std::move(widget), }); } + if (const auto session = now ? &now->session() : nullptr) { + for (const auto &channelPost : _channelPosts) { + _areas.push_back({ + .original = channelPost.area.geometry, + .rotation = channelPost.area.rotation, + .handler = MakeChannelPostHandler( + session, + channelPost.itemId), + }); + } + } rebuildActiveAreas(*layout); } diff --git a/Telegram/SourceFiles/media/stories/media_stories_controller.h b/Telegram/SourceFiles/media/stories/media_stories_controller.h index db494d9ee..8943a9e84 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_controller.h +++ b/Telegram/SourceFiles/media/stories/media_stories_controller.h @@ -302,6 +302,7 @@ private: std::vector _locations; std::vector _suggestedReactions; + std::vector _channelPosts; mutable std::vector _areas; std::vector _cachedSourcesList; diff --git a/Telegram/SourceFiles/mtproto/scheme/api.tl b/Telegram/SourceFiles/mtproto/scheme/api.tl index 7a71a7088..879e2ba0e 100644 --- a/Telegram/SourceFiles/mtproto/scheme/api.tl +++ b/Telegram/SourceFiles/mtproto/scheme/api.tl @@ -1152,7 +1152,7 @@ account.wallPapers#cdc3858c hash:long wallpapers:Vector = account.Wal codeSettings#ad253d78 flags:# allow_flashcall:flags.0?true current_number:flags.1?true allow_app_hash:flags.4?true allow_missed_call:flags.5?true allow_firebase:flags.7?true logout_tokens:flags.6?Vector token:flags.8?string app_sandbox:flags.8?Bool = CodeSettings; -wallPaperSettings#1dc1bca4 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int second_background_color:flags.4?int third_background_color:flags.5?int fourth_background_color:flags.6?int intensity:flags.3?int rotation:flags.4?int = WallPaperSettings; +wallPaperSettings#372efcd0 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int second_background_color:flags.4?int third_background_color:flags.5?int fourth_background_color:flags.6?int intensity:flags.3?int rotation:flags.4?int emoticon:flags.7?string = WallPaperSettings; autoDownloadSettings#baa57628 flags:# disabled:flags.0?true video_preload_large:flags.1?true audio_preload_next:flags.2?true phonecalls_less_data:flags.3?true stories_preload:flags.4?true photo_size_max:int video_size_max:long file_size_max:long video_upload_maxbitrate:int small_queue_active_operations_max:int large_queue_active_operations_max:int = AutoDownloadSettings; @@ -1623,7 +1623,7 @@ peerColor#b54b5acf flags:# color:flags.0?int background_emoji_id:flags.1?long = help.peerColorSet#26219a58 colors:Vector = help.PeerColorSet; help.peerColorProfileSet#767d61eb palette_colors:Vector bg_colors:Vector story_colors:Vector = help.PeerColorSet; -help.peerColorOption#135bd42f flags:# hidden:flags.0?true color_id:int colors:flags.1?help.PeerColorSet dark_colors:flags.2?help.PeerColorSet = help.PeerColorOption; +help.peerColorOption#ef8430ab flags:# hidden:flags.0?true color_id:int colors:flags.1?help.PeerColorSet dark_colors:flags.2?help.PeerColorSet channel_min_level:flags.3?int = help.PeerColorOption; help.peerColorsNotModified#2ba1f5ce = help.PeerColors; help.peerColors#f8ed08 hash:int colors:Vector = help.PeerColors;