Fix handling of 0 min boost level.

This commit is contained in:
levlam 2024-02-12 22:59:12 +03:00
parent 767336fb21
commit 02d1cef461

View File

@ -462,29 +462,33 @@ ThemeManager::DialogBoostAvailableCounts ThemeManager::get_dialog_boost_availabl
: Slice("channel_wallpaper_level_min"))) { : Slice("channel_wallpaper_level_min"))) {
result.chat_theme_count_ = static_cast<int32>(chat_themes_.themes.size()); result.chat_theme_count_ = static_cast<int32>(chat_themes_.themes.size());
} }
auto &min_boost_levels = {
for_megagroup ? accent_colors_.min_megagroup_boost_levels_ : accent_colors_.min_broadcast_boost_levels_; auto &min_boost_levels =
for (size_t i = 0; i < min_boost_levels.size(); i++) { for_megagroup ? accent_colors_.min_megagroup_boost_levels_ : accent_colors_.min_broadcast_boost_levels_;
if (level >= min_boost_levels[i]) { for (size_t i = 0; i < min_boost_levels.size(); i++) {
result.accent_color_count_++; if (level >= min_boost_levels[i] && min_boost_levels[i] != 0) {
result.accent_color_count_++;
if (accent_colors_.accent_color_ids_[i].is_built_in()) { if (accent_colors_.accent_color_ids_[i].is_built_in()) {
result.title_color_count_++; result.title_color_count_++;
continue; continue;
} }
auto it = accent_colors_.light_colors_.find(accent_colors_.accent_color_ids_[i]); auto it = accent_colors_.light_colors_.find(accent_colors_.accent_color_ids_[i]);
CHECK(it != accent_colors_.light_colors_.end()); CHECK(it != accent_colors_.light_colors_.end());
if (it->second.size() == 1) { if (it->second.size() == 1) {
result.title_color_count_++; result.title_color_count_++;
}
} }
} }
} }
auto &min_profile_boost_levels = for_megagroup ? profile_accent_colors_.min_megagroup_boost_levels_ {
: profile_accent_colors_.min_broadcast_boost_levels_; auto &min_profile_boost_levels = for_megagroup ? profile_accent_colors_.min_megagroup_boost_levels_
for (size_t i = 0; i < min_profile_boost_levels.size(); i++) { : profile_accent_colors_.min_broadcast_boost_levels_;
if (level >= min_profile_boost_levels[i]) { for (size_t i = 0; i < min_profile_boost_levels.size(); i++) {
result.profile_accent_color_count_++; if (level >= min_profile_boost_levels[i] && min_profile_boost_levels[i] != 0) {
result.profile_accent_color_count_++;
}
} }
} }
return result; return result;