diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 5e6a8dc3f..9e3f181e3 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2226,6 +2226,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_boost_reassign_done#other" = "{count} boosts are reassigned from {channels}."; "lng_boost_reassign_channels#one" = "{count} channel"; "lng_boost_reassign_channels#other" = "{count} channels"; +"lng_boost_reassign_groups#one" = "{count} group"; +"lng_boost_reassign_groups#other" = "{count} groups"; +"lng_boost_reassign_mixed#one" = "{count} group or channel"; +"lng_boost_reassign_mixed#other" = "{count} groups and channels"; "lng_boost_channel_title_color" = "Enable colors"; "lng_boost_channel_needs_level_color#one" = "Your channel needs to reach **Level {count}** to change channel color."; @@ -2321,8 +2325,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_giveaway_duration_price" = "{price} x {amount}"; "lng_giveaway_date_select" = "Select Date and Time"; "lng_giveaway_date_confirm" = "Confirm"; -"lng_giveaway_channels_select#one" = "Select up to {count} channel"; -"lng_giveaway_channels_select#other" = "Select up to {count} channels"; "lng_giveaway_recipients_save" = "Save Recipients"; "lng_giveaway_recipients_deselect" = "Deselect All"; "lng_giveaway_maximum_countries_error#one" = "You can select maximum {count} country."; diff --git a/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp b/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp index 494996dbb..ef99b3a90 100644 --- a/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp @@ -340,14 +340,15 @@ object_ptr ReassignBoostFloodBox(int seconds, bool group) { object_ptr ReassignBoostSingleBox( not_null to, TakenBoostSlot from, - Fn slots, int sources)> reassign, + Fn slots, int groups, int channels)> reassign, Fn cancel) { const auto reassigned = std::make_shared(); const auto slot = from.id; const auto peer = to->owner().peer(from.peerId); + const auto group = peer->isMegagroup(); const auto confirmed = [=](Fn close) { *reassigned = true; - reassign({ slot }, 1); + reassign({ slot }, group ? 1 : 0, group ? 0 : 1); close(); }; @@ -442,7 +443,10 @@ Ui::BoostFeatures LookupBoostFeatures(not_null channel) { } ++linkStylesByLevel[level]; } - + const auto &themes = channel->owner().cloudThemes().chatThemes(); + if (themes.empty()) { + channel->owner().cloudThemes().refreshChatThemes(); + } return Ui::BoostFeatures{ .nameColorsByLevel = std::move(nameColorsByLevel), .linkStylesByLevel = std::move(linkStylesByLevel), @@ -455,8 +459,7 @@ Ui::BoostFeatures LookupBoostFeatures(not_null channel) { .wallpaperLevel = get(group ? u"group_wallpaper_level_min"_q : u"channel_wallpaper_level_min"_q, 9), - .wallpapersCount = int( - channel->owner().cloudThemes().chatThemes().size()), + .wallpapersCount = themes.empty() ? 8 : int(themes.size()), .customWallpaperLevel = get(group ? u"channel_custom_wallpaper_level_min"_q : u"group_custom_wallpaper_level_min"_q, 10), @@ -468,23 +471,37 @@ int BoostsForGift(not_null session) { return session->account().appConfig().get(key, 0); } -[[nodiscard]] int SourcesCount( +struct Sources { + int groups = 0; + int channels = 0; +}; +[[nodiscard]] Sources SourcesCount( + not_null to, const std::vector &from, const std::vector &slots) { - auto checked = base::flat_set(); - checked.reserve(slots.size()); + auto groups = base::flat_set(); + groups.reserve(slots.size()); + auto channels = base::flat_set(); + channels.reserve(slots.size()); + const auto owner = &to->owner(); for (const auto slot : slots) { const auto i = ranges::find(from, slot, &TakenBoostSlot::id); Assert(i != end(from)); - checked.emplace(i->peerId); + const auto id = i->peerId; + if (!groups.contains(id) && !channels.contains(id)) { + (owner->peer(id)->isMegagroup() ? groups : channels).insert(id); + } } - return checked.size(); + return { + .groups = int(groups.size()), + .channels = int(channels.size()), + }; } object_ptr ReassignBoostsBox( not_null to, std::vector from, - Fn slots, int sources)> reassign, + Fn slots, int groups, int channels)> reassign, Fn cancel) { Expects(!from.empty()); @@ -505,10 +522,10 @@ object_ptr ReassignBoostsBox( ) | rpl::start_with_next([=](std::vector slots) { box->clearButtons(); if (!slots.empty()) { - const auto sources = SourcesCount(from, slots); + const auto sources = SourcesCount(to, from, slots); box->addButton(tr::lng_boost_reassign_button(), [=] { *reassigned = true; - reassign(slots, sources); + reassign(slots, sources.groups, sources.channels); }); } box->addButton(tr::lng_cancel(), [=] { diff --git a/Telegram/SourceFiles/boxes/peers/replace_boost_box.h b/Telegram/SourceFiles/boxes/peers/replace_boost_box.h index 74ab7e093..0f7d01106 100644 --- a/Telegram/SourceFiles/boxes/peers/replace_boost_box.h +++ b/Telegram/SourceFiles/boxes/peers/replace_boost_box.h @@ -50,7 +50,7 @@ struct ForChannelBoostSlots { object_ptr ReassignBoostsBox( not_null to, std::vector from, - Fn slots, int sources)> reassign, + Fn slots, int groups, int channels)> reassign, Fn cancel); [[nodiscard]] object_ptr CreateBoostReplaceUserpics( diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 8b099aa15..92727609d 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -684,7 +684,10 @@ void SessionNavigation::applyBoost( done({}); } else { const auto weak = std::make_shared>(); - const auto reassign = [=](std::vector slots, int sources) { + const auto reassign = [=]( + std::vector slots, + int groups, + int channels) { const auto count = int(slots.size()); const auto callback = [=](Ui::BoostCounters counters) { if (const auto strong = weak->data()) { @@ -696,10 +699,14 @@ void SessionNavigation::applyBoost( lt_count, count, lt_channels, - tr::lng_boost_reassign_channels( - tr::now, - lt_count, - sources))); + (!groups + ? tr::lng_boost_reassign_channels + : !channels + ? tr::lng_boost_reassign_groups + : tr::lng_boost_reassign_mixed)( + tr::now, + lt_count, + groups + channels))); }; applyBoostsChecked( channel,