From 16ce5ef046521bbbdb8e7def1f91379b6378520b Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 1 May 2024 12:47:12 +0400 Subject: [PATCH] Greeting category first in ChatIntro setup. --- .../chat_helpers/stickers_list_widget.cpp | 2 ++ .../chat_helpers/stickers_list_widget.h | 1 + .../chat_helpers/tabbed_selector.cpp | 27 ++++++++++++++++--- .../chat_helpers/tabbed_selector.h | 2 ++ .../settings/business/settings_chat_intro.cpp | 2 +- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 07a02caa9..e44b8aaef 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -2619,6 +2619,8 @@ void StickersListWidget::setupSearch() { const auto session = &_show->session(); const auto type = (_mode == Mode::UserpicBuilder) ? TabbedSearchType::ProfilePhoto + : (_mode == Mode::ChatIntro) + ? TabbedSearchType::Greeting : TabbedSearchType::Stickers; _search = MakeSearch(this, st(), [=](std::vector &&query) { auto set = base::flat_set(); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h index 2e1ef9c1c..aff2cf287 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h @@ -65,6 +65,7 @@ enum class StickersListMode { Full, Masks, UserpicBuilder, + ChatIntro, }; struct StickersListDescriptor { diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index 7f8a915c7..7de254bad 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -302,6 +302,21 @@ void TabbedSelector::Tab::saveScrollTop() { _scrollTop = widget()->getVisibleTop(); } +[[nodiscard]] rpl::producer> GreetingGroupFirst( + not_null owner) { + return owner->emojiStatuses().stickerGroupsValue( + ) | rpl::map([](std::vector &&groups) { + const auto i = ranges::find( + groups, + Ui::EmojiGroupType::Greeting, + &Ui::EmojiGroup::type); + if (i != begin(groups) && i != end(groups)) { + ranges::rotate(begin(groups), i, i + 1); + } + return std::move(groups); + }); +} + std::unique_ptr MakeSearch( not_null parent, const style::EmojiPan &st, @@ -318,6 +333,8 @@ std::unique_ptr MakeSearch( ? owner->emojiStatuses().statusGroupsValue() : (type == TabbedSearchType::Stickers) ? owner->emojiStatuses().stickerGroupsValue() + : (type == TabbedSearchType::Greeting) + ? GreetingGroupFirst(owner) : owner->emojiStatuses().emojiGroupsValue()), .customEmojiFactory = owner->customEmojiManager().factory( Data::CustomEmojiManager::SizeTag::SetIcon, @@ -379,7 +396,7 @@ TabbedSelector::TabbedSelector( tabs.reserve(2); tabs.push_back(createTab(SelectorTab::Stickers, 0)); tabs.push_back(createTab(SelectorTab::Masks, 1)); - } else if (_mode == Mode::StickersOnly) { + } else if (_mode == Mode::StickersOnly || _mode == Mode::ChatIntro) { tabs.reserve(1); tabs.push_back(createTab(SelectorTab::Stickers, 0)); } else { @@ -390,7 +407,9 @@ TabbedSelector::TabbedSelector( }()) , _currentTabType(full() ? session().settings().selectorTab() - : (mediaEditor() || _mode == Mode::StickersOnly) + : (mediaEditor() + || _mode == Mode::StickersOnly + || _mode == Mode::ChatIntro) ? SelectorTab::Stickers : SelectorTab::Emoji) , _hasEmojiTab(ranges::contains(_tabs, SelectorTab::Emoji, &Tab::type)) @@ -555,7 +574,9 @@ TabbedSelector::Tab TabbedSelector::createTab(SelectorTab type, int index) { using Descriptor = StickersListDescriptor; return object_ptr(this, Descriptor{ .show = _show, - .mode = StickersMode::Full, + .mode = (_mode == Mode::ChatIntro + ? StickersMode::ChatIntro + : StickersMode::Full), .paused = paused, .st = &_st, .features = _features, diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h index f663d470a..b9b03b33b 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h @@ -87,6 +87,7 @@ enum class TabbedSelectorMode { FullReactions, RecentReactions, PeerTitle, + ChatIntro, }; struct TabbedSelectorDescriptor { @@ -103,6 +104,7 @@ enum class TabbedSearchType { Status, ProfilePhoto, Stickers, + Greeting, }; [[nodiscard]] std::unique_ptr MakeSearch( not_null parent, diff --git a/Telegram/SourceFiles/settings/business/settings_chat_intro.cpp b/Telegram/SourceFiles/settings/business/settings_chat_intro.cpp index 7bd61ca90..b8a7607f6 100644 --- a/Telegram/SourceFiles/settings/business/settings_chat_intro.cpp +++ b/Telegram/SourceFiles/settings/business/settings_chat_intro.cpp @@ -476,7 +476,7 @@ void StickerPanel::create(const Descriptor &descriptor) { .show = controller->uiShow(), .st = st::backgroundEmojiPan, .level = Window::GifPauseReason::Layer, - .mode = Mode::StickersOnly, + .mode = Mode::ChatIntro, .features = { .megagroupSet = false, .stickersSettings = false,