diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 2d00c68e7b..2290231cee 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3773,6 +3773,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_gift_collection_empty_text" = "Add some of your gifts to this collection."; "lng_gift_collection_all" = "All Gifts"; "lng_gift_collection_add_title" = "Add Gifts"; +"lng_gift_collection_share" = "Share Collection"; "lng_gift_collection_edit" = "Edit Name"; "lng_gift_collection_limit_title" = "Limit Reached"; "lng_gift_collection_limit_text" = "Please remove one of the existing collections to add a new one."; @@ -6267,6 +6268,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_view_button_collectible" = "View collectible"; "lng_view_button_call" = "Join call"; "lng_view_button_storyalbum" = "View Album"; +"lng_view_button_collection" = "View Collection"; "lng_sponsored_hide_ads" = "Hide"; "lng_sponsored_title" = "What are sponsored messages?"; diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index b2481979f6..7f76e19cda 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -635,6 +635,8 @@ bool ResolveUsernameOrPhone( const auto storyId = storyParam.toInt(); const auto storyAlbumParam = params.value(u"album"_q); const auto storyAlbumId = storyAlbumParam.toInt(); + const auto giftCollectionParam = params.value(u"collection"_q); + const auto giftCollectionId = giftCollectionParam.toInt(); const auto appname = webChannelPreviewLink ? QString() : appnameParam; const auto commentParam = params.value(u"comment"_q); const auto commentId = commentParam.toInt(); @@ -662,6 +664,7 @@ bool ResolveUsernameOrPhone( .messageId = post, .storyId = storyId, .storyAlbumId = storyAlbumId, + .giftCollectionId = giftCollectionId, .videoTimestamp = (!videot.isEmpty() ? ParseVideoTimestamp(videot) : std::optional()), @@ -1847,6 +1850,7 @@ QString TryConvertUrlToLocal(QString url) { "/\\d+/?(\\?|$)|" "/s/\\d+/?(\\?|$)|" "/a/\\d+/?(\\?|$)|" + "/c/\\d+/?(\\?|$)|" "/\\d+/\\d+/?(\\?|$)" ")"_q, query, matchOptions)) { const auto domain = usernameMatch->captured(1); @@ -1869,8 +1873,10 @@ QString TryConvertUrlToLocal(QString url) { added = u"&post="_q + postMatch->captured(1); } else if (const auto storyMatch = regex_match(u"^/s/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) { added = u"&story="_q + storyMatch->captured(1); - } else if (const auto storyMatch = regex_match(u"^/a/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) { - added = u"&album="_q + storyMatch->captured(1); + } else if (const auto albumMatch = regex_match(u"^/a/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) { + added = u"&album="_q + albumMatch->captured(1); + } else if (const auto collectionMatch = regex_match(u"^/c/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) { + added = u"&collection="_q + collectionMatch->captured(1); } else if (const auto appNameMatch = regex_match(u"^/([a-zA-Z0-9\\.\\_\\-]+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) { added = u"&appname="_q + appNameMatch->captured(1); } diff --git a/Telegram/SourceFiles/data/data_file_origin.cpp b/Telegram/SourceFiles/data/data_file_origin.cpp index e92845840f..db84988af0 100644 --- a/Telegram/SourceFiles/data/data_file_origin.cpp +++ b/Telegram/SourceFiles/data/data_file_origin.cpp @@ -61,6 +61,8 @@ struct FileReferenceAccumulator { push(data.vstickers()); }, [&](const MTPDwebPageAttributeUniqueStarGift &data) { push(data.vgift()); + }, [&](const MTPDwebPageAttributeStarGiftCollection &data) { + push(data.vicons()); }); } void push(const MTPStarGift &data) { diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 9468425002..88a62f1494 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -3798,6 +3798,8 @@ void Session::webpageApplyFields( return (DocumentData*)nullptr; }, [](const MTPDwebPageAttributeUniqueStarGift &) { return (DocumentData*)nullptr; + }, [](const MTPDwebPageAttributeStarGiftCollection &) { + return (DocumentData*)nullptr; }); if (result) { return result; @@ -3820,6 +3822,14 @@ void Session::webpageApplyFields( result->items.push_back(processDocument(tl)); } return result; + }, [&](const MTPDwebPageAttributeStarGiftCollection &data) { + auto result = std::make_unique(); + result->isEmoji = false; + result->isTextColor = false; + for (const auto &tl : data.vicons().v) { + result->items.push_back(processDocument(tl)); + } + return result; }, [](const auto &) { return WebPageStickerSetPtr(nullptr); }); diff --git a/Telegram/SourceFiles/data/data_web_page.cpp b/Telegram/SourceFiles/data/data_web_page.cpp index 6293cf2616..9c63bb1118 100644 --- a/Telegram/SourceFiles/data/data_web_page.cpp +++ b/Telegram/SourceFiles/data/data_web_page.cpp @@ -175,6 +175,8 @@ WebPageType ParseWebPageType( return WebPageType::StickerSet; } else if (type == u"telegram_story_album"_q) { return WebPageType::StoryAlbum; + } else if (type == u"telegram_collection"_q) { + return WebPageType::GiftCollection; } else if (hasIV) { return WebPageType::ArticleWithIV; } else { diff --git a/Telegram/SourceFiles/data/data_web_page.h b/Telegram/SourceFiles/data/data_web_page.h index 4fd2d4ab73..68abfe1c98 100644 --- a/Telegram/SourceFiles/data/data_web_page.h +++ b/Telegram/SourceFiles/data/data_web_page.h @@ -50,6 +50,7 @@ enum class WebPageType : uint8 { Story, StickerSet, StoryAlbum, + GiftCollection, Article, ArticleWithIV, diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index 5b64cb2d01..aa21c16a3b 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -234,6 +234,8 @@ constexpr auto kSponsoredUserpicLines = 2; ? tr::lng_view_button_stickerset(tr::now) : (type == WebPageType::StoryAlbum) ? tr::lng_view_button_storyalbum(tr::now) + : (type == WebPageType::GiftCollection) + ? tr::lng_view_button_collection(tr::now) : QString()); if (page->iv) { const auto manager = &page->owner().customEmojiManager(); @@ -272,7 +274,9 @@ constexpr auto kSponsoredUserpicLines = 2; || ((type == WebPageType::WallPaper) && webpage->document && webpage->document->isWallPaper()) - || (type == WebPageType::StickerSet); + || (type == WebPageType::StickerSet) + || (type == WebPageType::StoryAlbum) + || (type == WebPageType::GiftCollection); } } // namespace diff --git a/Telegram/SourceFiles/info/info_content_widget.cpp b/Telegram/SourceFiles/info/info_content_widget.cpp index bdba718d5f..c696a6973e 100644 --- a/Telegram/SourceFiles/info/info_content_widget.cpp +++ b/Telegram/SourceFiles/info/info_content_widget.cpp @@ -17,6 +17,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/profile/info_profile_widget.h" #include "info/media/info_media_widget.h" #include "info/common_groups/info_common_groups_widget.h" +#include "info/peer_gifts/info_peer_gifts_common.h" +#include "info/stories/info_stories_common.h" #include "info/info_layer_widget.h" #include "info/info_section_widget.h" #include "info/info_controller.h" @@ -476,6 +478,11 @@ Key ContentMemento::key() const { return Key(poll, pollContextId()); } else if (const auto self = settingsSelf()) { return Settings::Tag{ self }; + } else if (const auto gifts = giftsPeer()) { + return PeerGifts::Tag{ + gifts, + giftsCollectionId(), + }; } else if (const auto stories = storiesPeer()) { return Stories::Tag{ stories, @@ -529,6 +536,11 @@ ContentMemento::ContentMemento(Stories::Tag stories) , _storiesAddToAlbumId(stories.addingToAlbumId) { } +ContentMemento::ContentMemento(PeerGifts::Tag gifts) +: _giftsPeer(gifts.peer) +, _giftsCollectionId(gifts.collectionId) { +} + ContentMemento::ContentMemento(Statistics::Tag statistics) : _statisticsTag(statistics) { } diff --git a/Telegram/SourceFiles/info/info_content_widget.h b/Telegram/SourceFiles/info/info_content_widget.h index 52d6e2e5af..647124d0b7 100644 --- a/Telegram/SourceFiles/info/info_content_widget.h +++ b/Telegram/SourceFiles/info/info_content_widget.h @@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "info/info_wrap_widget.h" -#include "info/stories/info_stories_common.h" #include "info/statistics/info_statistics_tag.h" #include "ui/controls/swipe_handler_data.h" @@ -61,6 +60,14 @@ namespace Info::GlobalMedia { struct Tag; } // namespace Info::GlobalMedia +namespace Info::PeerGifts { +struct Tag; +} // namespace Info::PeerGifts + +namespace Info::Stories { +struct Tag; +} // namespace Info::Stories + namespace Info { class ContentMemento; @@ -208,6 +215,7 @@ public: Data::ForumTopic *topic, Data::SavedSublist *sublist, PeerId migratedPeerId); + explicit ContentMemento(PeerGifts::Tag gifts); explicit ContentMemento(Settings::Tag settings); explicit ContentMemento(Downloads::Tag downloads); explicit ContentMemento(Stories::Tag stories); @@ -253,6 +261,12 @@ public: [[nodiscard]] int storiesAddToAlbumId() const { return _storiesAddToAlbumId; } + [[nodiscard]] PeerData *giftsPeer() const { + return _giftsPeer; + } + [[nodiscard]] int giftsCollectionId() const { + return _giftsCollectionId; + } [[nodiscard]] Statistics::Tag statisticsTag() const { return _statisticsTag; } @@ -319,6 +333,8 @@ private: PeerData * const _storiesPeer = nullptr; int _storiesAlbumId = 0; int _storiesAddToAlbumId = 0; + PeerData * const _giftsPeer = nullptr; + int _giftsCollectionId = 0; Statistics::Tag _statisticsTag; PeerData * const _starrefPeer = nullptr; BotStarRef::Type _starrefType = {}; diff --git a/Telegram/SourceFiles/info/info_controller.cpp b/Telegram/SourceFiles/info/info_controller.cpp index 047d2e0a64..64b171919c 100644 --- a/Telegram/SourceFiles/info/info_controller.cpp +++ b/Telegram/SourceFiles/info/info_controller.cpp @@ -52,6 +52,9 @@ Key::Key(Stories::Tag stories) : _value(stories) { Key::Key(Statistics::Tag statistics) : _value(statistics) { } +Key::Key(PeerGifts::Tag gifts) : _value(gifts) { +} + Key::Key(BotStarRef::Tag starref) : _value(starref) { } @@ -132,6 +135,20 @@ int Key::storiesAddToAlbumId() const { return 0; } +PeerData *Key::giftsPeer() const { + if (const auto tag = std::get_if(&_value)) { + return tag->peer; + } + return nullptr; +} + +int Key::giftsCollectionId() const { + if (const auto tag = std::get_if(&_value)) { + return tag->collectionId; + } + return 0; +} + Statistics::Tag Key::statisticsTag() const { if (const auto tag = std::get_if(&_value)) { return *tag; diff --git a/Telegram/SourceFiles/info/info_controller.h b/Telegram/SourceFiles/info/info_controller.h index f80b4ef3a1..5c3bfe46a0 100644 --- a/Telegram/SourceFiles/info/info_controller.h +++ b/Telegram/SourceFiles/info/info_controller.h @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_message_reaction_id.h" #include "data/data_search_controller.h" +#include "info/peer_gifts/info_peer_gifts_common.h" #include "info/statistics/info_statistics_tag.h" #include "info/stories/info_stories_common.h" #include "window/window_session_controller.h" @@ -82,6 +83,7 @@ public: Key(Downloads::Tag downloads); Key(Stories::Tag stories); Key(Statistics::Tag statistics); + Key(PeerGifts::Tag gifts); Key(BotStarRef::Tag starref); Key(GlobalMedia::Tag global); Key(not_null poll, FullMsgId contextId); @@ -99,6 +101,8 @@ public: [[nodiscard]] PeerData *storiesPeer() const; [[nodiscard]] int storiesAlbumId() const; [[nodiscard]] int storiesAddToAlbumId() const; + [[nodiscard]] PeerData *giftsPeer() const; + [[nodiscard]] int giftsCollectionId() const; [[nodiscard]] Statistics::Tag statisticsTag() const; [[nodiscard]] PeerData *starrefPeer() const; [[nodiscard]] BotStarRef::Type starrefType() const; @@ -127,6 +131,7 @@ private: Downloads::Tag, Stories::Tag, Statistics::Tag, + PeerGifts::Tag, BotStarRef::Tag, GlobalMedia::Tag, PollKey, @@ -234,6 +239,12 @@ public: [[nodiscard]] int storiesAddToAlbumId() const { return key().storiesAddToAlbumId(); } + [[nodiscard]] PeerData *giftsPeer() const { + return key().giftsPeer(); + } + [[nodiscard]] int giftsCollectionId() const { + return key().giftsCollectionId(); + } [[nodiscard]] Statistics::Tag statisticsTag() const { return key().statisticsTag(); } diff --git a/Telegram/SourceFiles/info/info_memento.cpp b/Telegram/SourceFiles/info/info_memento.cpp index 945bda8736..48d883590b 100644 --- a/Telegram/SourceFiles/info/info_memento.cpp +++ b/Telegram/SourceFiles/info/info_memento.cpp @@ -211,8 +211,6 @@ std::shared_ptr Memento::DefaultContent( return std::make_shared(peer); case Section::Type::RequestsList: return std::make_shared(peer); - case Section::Type::PeerGifts: - return std::make_shared(peer); case Section::Type::SavedSublists: return std::make_shared(&peer->session()); case Section::Type::Members: diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index ec982a3f88..054ec8ce3f 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -446,7 +446,7 @@ void WrapWidget::setupTopBarMenuToggle() { addTopBarMenuButton(); } }, _topBar->lifetime()); - } else if (section.type() == Section::Type::PeerGifts && key.peer()) { + } else if (key.giftsPeer()) { addTopBarMenuButton(); } } diff --git a/Telegram/SourceFiles/info/media/info_media_buttons.cpp b/Telegram/SourceFiles/info/media/info_media_buttons.cpp index f40a2851b0..473a9558bd 100644 --- a/Telegram/SourceFiles/info/media/info_media_buttons.cpp +++ b/Telegram/SourceFiles/info/media/info_media_buttons.cpp @@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_chat_section.h" #include "info/info_controller.h" #include "info/info_memento.h" +#include "info/peer_gifts/info_peer_gifts_widget.h" #include "info/profile/info_profile_values.h" #include "info/stories/info_stories_widget.h" #include "main/main_session.h" @@ -386,10 +387,7 @@ not_null AddPeerGiftsButton( if (navigation->showFrozenError()) { return; } - navigation->showSection( - std::make_shared( - peer, - Section::Type::PeerGifts)); + navigation->showSection(Info::PeerGifts::Make(peer)); }); return wrap->entity(); } diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h index 4c16dbab78..8183cbaeeb 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h @@ -47,6 +47,16 @@ class SessionController; namespace Info::PeerGifts { +struct Tag { + explicit Tag(not_null peer, int collectionId = 0) + : peer(peer) + , collectionId(collectionId) { + } + + not_null peer; + int collectionId = 0; +}; + struct GiftTypePremium { int64 cost = 0; QString currency; diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp index d205cc5c24..63b983337b 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_hash.h" #include "api/api_premium.h" #include "apiwrap.h" +#include "boxes/share_box.h" #include "boxes/star_gift_box.h" #include "core/ui_integration.h" #include "data/stickers/data_custom_emoji.h" @@ -21,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/peer_gifts/info_peer_gifts_collections.h" #include "info/peer_gifts/info_peer_gifts_common.h" #include "info/info_controller.h" +#include "info/info_memento.h" #include "ui/boxes/confirm_box.h" #include "ui/controls/sub_tabs.h" #include "ui/layers/generic_box.h" @@ -129,6 +131,7 @@ public: void reloadCollection(int id); void editCollectionGifts(int id); + void shareCollectionLink(const QString &username, int id); void editCollectionName(int id); void confirmDeleteCollection(int id); void collectionAdded(MTPStarGiftCollection result); @@ -209,7 +212,7 @@ private: std::vector _collections; Entries _all; - base::flat_map _perCollection; + std::map _perCollection; not_null _entries; not_null*> _list; rpl::variable _collectionChanges; @@ -811,6 +814,11 @@ void InnerWidget::showMenuForCollection(int id) { addAction(tr::lng_gift_collection_add_title(tr::now), [=] { editCollectionGifts(id); }, &st::menuIconGiftPremium); + if (const auto username = _peer->username(); !username.isEmpty()) { + addAction(tr::lng_stories_album_share(tr::now), [=] { + shareCollectionLink(username, id); + }, &st::menuIconShare); + } addAction(tr::lng_gift_collection_edit(tr::now), [=] { editCollectionName(id); }, &st::menuIconEdit); @@ -823,6 +831,12 @@ void InnerWidget::showMenuForCollection(int id) { _menu->popup(QCursor::pos()); } +void InnerWidget::shareCollectionLink(const QString &username, int id) { + const auto url = _window->session().createInternalLinkFull( + username + u"/c/"_q + QString::number(id)); + FastShareLink(_window, url); +} + void InnerWidget::editCollectionName(int id) { const auto done = [=](QString name) { collectionRenamed(id, name); @@ -1190,9 +1204,17 @@ void InnerWidget::refreshCollectionsTabs() { .session = &_window->session(), }); if (!_collectionsTabs) { + const auto selectedId = _descriptor.current().collectionId; + const auto selected = (selectedId > 0 + && ranges::contains( + _collections, + selectedId, + &Data::GiftCollection::id)) + ? QString::number(selectedId) + : u"all"_q; _collectionsTabs = std::make_unique( this, - Ui::SubTabs::Options{ .selected = u"all"_q, .centered = true}, + Ui::SubTabs::Options{ .selected = selected, .centered = true }, std::move(tabs), context); _collectionsTabs->show(); @@ -1248,7 +1270,7 @@ void InnerWidget::collectionRemoved(int id) { _descriptorChanges.fire(std::move(now)); } Assert(_entries != &_perCollection[id]); - _perCollection.remove(id); + _perCollection.erase(id); const auto removeFrom = [&](Entries &entries) { for (auto &entry : entries.list) { entry.gift.collectionIds.erase( @@ -1439,8 +1461,14 @@ void InnerWidget::fillMenu(const Ui::Menu::MenuCallback &addAction) { } } -Memento::Memento(not_null peer) -: ContentMemento(peer, nullptr, nullptr, PeerId()) { +Memento::Memento(not_null controller) +: ContentMemento(Tag{ + controller->giftsPeer(), + controller->giftsCollectionId() }) { +} + +Memento::Memento(not_null peer, int collectionId) +: ContentMemento(Tag{ peer, collectionId }) { } Section Memento::section() const { @@ -1451,7 +1479,7 @@ object_ptr Memento::createWidget( QWidget *parent, not_null controller, const QRect &geometry) { - auto result = object_ptr(parent, controller, peer()); + auto result = object_ptr(parent, controller); result->setInternalState(geometry, this); return result; } @@ -1466,16 +1494,16 @@ std::unique_ptr Memento::listState() { Memento::~Memento() = default; -Widget::Widget( - QWidget *parent, - not_null controller, - not_null peer) -: ContentWidget(parent, controller) { +Widget::Widget(QWidget *parent, not_null controller) +: ContentWidget(parent, controller) +, _descriptor(Descriptor{ + .collectionId = controller->giftsCollectionId(), +}) { _inner = setInnerWidget( object_ptr( this, controller->parentController(), - peer, + controller->giftsPeer(), _descriptor.value())); _inner->notifyEnabled( ) | rpl::take(1) | rpl::start_with_next([=](bool enabled) { @@ -1694,7 +1722,7 @@ void Widget::setInternalState( } std::shared_ptr Widget::doCreateMemento() { - auto result = std::make_shared(peer()); + auto result = std::make_shared(controller()); saveState(result.get()); return result; } @@ -1709,4 +1737,11 @@ void Widget::restoreState(not_null memento) { scrollTopRestore(memento->scrollTop()); } +std::shared_ptr Make(not_null peer, int albumId) { + return std::make_shared( + std::vector>( + 1, + std::make_shared(peer, albumId))); +} + } // namespace Info::PeerGifts diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.h b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.h index 852d1c2744..bf33486e97 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.h +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.h @@ -58,7 +58,9 @@ class InnerWidget; class Memento final : public ContentMemento { public: - explicit Memento(not_null peer); + Memento(not_null controller); + Memento(not_null peer, int collectionId); + ~Memento(); object_ptr createWidget( QWidget *parent, @@ -70,8 +72,6 @@ public: void setListState(std::unique_ptr state); std::unique_ptr listState(); - ~Memento(); - private: std::unique_ptr _listState; @@ -79,10 +79,7 @@ private: class Widget final : public ContentWidget { public: - Widget( - QWidget *parent, - not_null controller, - not_null peer); + Widget(QWidget *parent, not_null controller); [[nodiscard]] not_null peer() const; @@ -120,4 +117,8 @@ private: }; +[[nodiscard]] std::shared_ptr Make( + not_null peer, + int collectionId = 0); + } // namespace Info::PeerGifts diff --git a/Telegram/SourceFiles/info/stories/info_stories_inner_widget.cpp b/Telegram/SourceFiles/info/stories/info_stories_inner_widget.cpp index 43d38c2e02..ba762f044f 100644 --- a/Telegram/SourceFiles/info/stories/info_stories_inner_widget.cpp +++ b/Telegram/SourceFiles/info/stories/info_stories_inner_widget.cpp @@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "dialogs/ui/dialogs_stories_list.h" #include "info/media/info_media_buttons.h" #include "info/media/info_media_list_widget.h" +#include "info/peer_gifts/info_peer_gifts_widget.h" #include "info/profile/info_profile_actions.h" #include "info/profile/info_profile_icon.h" #include "info/profile/info_profile_values.h" @@ -456,10 +457,7 @@ void InnerWidget::addGiftsButton(Ui::MultiSlideTracker &tracker) { const auto gifts = giftsWrap->entity(); gifts->addClickHandler([=] { - _controller->showSection( - std::make_shared( - user, - Section::Type::PeerGifts)); + _controller->showSection(PeerGifts::Make(_peer)); }); auto label = rpl::duplicate( count diff --git a/Telegram/SourceFiles/info/stories/info_stories_widget.cpp b/Telegram/SourceFiles/info/stories/info_stories_widget.cpp index 9722ba9453..68b751a2e5 100644 --- a/Telegram/SourceFiles/info/stories/info_stories_widget.cpp +++ b/Telegram/SourceFiles/info/stories/info_stories_widget.cpp @@ -25,7 +25,8 @@ int ArchiveId() { Memento::Memento(not_null controller) : ContentMemento(Tag{ controller->storiesPeer(), - controller->storiesAlbumId() }) + controller->storiesAlbumId(), + controller->storiesAddToAlbumId() }) , _media(controller) { } diff --git a/Telegram/SourceFiles/mtproto/scheme/api.tl b/Telegram/SourceFiles/mtproto/scheme/api.tl index 2db91068b7..e520e1cf42 100644 --- a/Telegram/SourceFiles/mtproto/scheme/api.tl +++ b/Telegram/SourceFiles/mtproto/scheme/api.tl @@ -1289,6 +1289,7 @@ webPageAttributeTheme#54b56617 flags:# documents:flags.0?Vector settin webPageAttributeStory#2e94c3e7 flags:# peer:Peer id:int story:flags.0?StoryItem = WebPageAttribute; webPageAttributeStickerSet#50cc03d3 flags:# emojis:flags.0?true text_color:flags.1?true stickers:Vector = WebPageAttribute; webPageAttributeUniqueStarGift#cf6f6db8 gift:StarGift = WebPageAttribute; +webPageAttributeStarGiftCollection#31cad303 icons:Vector = WebPageAttribute; messages.votesList#4899484e flags:# count:int votes:Vector chats:Vector users:Vector next_offset:flags.0?string = messages.VotesList; diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 4196b62046..6a44af2a85 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -47,6 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/channel_statistics/earn/earn_format.h" #include "info/channel_statistics/earn/earn_icons.h" #include "info/peer_gifts/info_peer_gifts_common.h" +#include "info/peer_gifts/info_peer_gifts_widget.h" #include "info/settings/info_settings_widget.h" // SectionCustomTopBarData. #include "info/statistics/info_statistics_list_controllers.h" #include "info/info_controller.h" @@ -1775,9 +1776,7 @@ void GenericCreditsEntryBox( if (ok && showSection) { if (const auto window = show->resolveWindow()) { window->showSection( - std::make_shared( - window->session().user(), - Info::Section::Type::PeerGifts)); + Info::PeerGifts::Make(window->session().user())); } } if (const auto strong = weak.get()) { diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 2c4f9e0ae8..3a69f7b057 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_filters_menu.h" #include "window/window_separate_id.h" #include "info/channel_statistics/earn/info_channel_earn_list.h" +#include "info/peer_gifts/info_peer_gifts_widget.h" #include "info/stories/info_stories_widget.h" #include "info/info_memento.h" #include "info/info_controller.h" @@ -655,6 +656,8 @@ void SessionNavigation::showPeerByLinkResolved( })); } else if (info.storyAlbumId > 0) { showSection(Info::Stories::Make(peer, info.storyAlbumId)); + } else if (info.giftCollectionId > 0) { + showSection(Info::PeerGifts::Make(peer, info.giftCollectionId)); } else if (bot && resolveType == ResolveType::BotApp) { const auto itemId = info.clickFromMessageId; const auto item = _session->data().message(itemId); diff --git a/Telegram/SourceFiles/window/window_session_controller_link_info.h b/Telegram/SourceFiles/window/window_session_controller_link_info.h index 7421aac748..bf6ecc2be7 100644 --- a/Telegram/SourceFiles/window/window_session_controller_link_info.h +++ b/Telegram/SourceFiles/window/window_session_controller_link_info.h @@ -41,6 +41,7 @@ struct PeerByLinkInfo { MsgId messageId = ShowAtUnreadMsgId; StoryId storyId = 0; int storyAlbumId = 0; + int giftCollectionId = 0; std::optional videoTimestamp; QString text; RepliesByLinkInfo repliesInfo;