Add profileAccentColor.min_supergroup_boost_level.
This commit is contained in:
parent
9400447fde
commit
29d4de052e
@ -761,8 +761,9 @@ profileAccentColors palette_colors:vector<int32> background_colors:vector<int32>
|
|||||||
//@id Profile accent color identifier
|
//@id Profile accent color identifier
|
||||||
//@light_theme_colors Accent colors expected to be used in light themes
|
//@light_theme_colors Accent colors expected to be used in light themes
|
||||||
//@dark_theme_colors Accent colors expected to be used in dark themes
|
//@dark_theme_colors Accent colors expected to be used in dark themes
|
||||||
//@min_chat_boost_level The minimum chat boost level required to use the color
|
//@min_supergroup_chat_boost_level The minimum chat boost level required to use the color in a supergroup chat
|
||||||
profileAccentColor id:int32 light_theme_colors:profileAccentColors dark_theme_colors:profileAccentColors min_chat_boost_level:int32 = ProfileAccentColor;
|
//@min_channel_chat_boost_level The minimum chat boost level required to use the color in a channel chat
|
||||||
|
profileAccentColor id:int32 light_theme_colors:profileAccentColors dark_theme_colors:profileAccentColors min_supergroup_chat_boost_level:int32 min_channel_chat_boost_level:int32 = ProfileAccentColor;
|
||||||
|
|
||||||
//@description Describes a custom emoji to be shown instead of the Telegram Premium badge
|
//@description Describes a custom emoji to be shown instead of the Telegram Premium badge
|
||||||
//@custom_emoji_id Identifier of the custom emoji in stickerFormatTgs format
|
//@custom_emoji_id Identifier of the custom emoji in stickerFormatTgs format
|
||||||
|
@ -348,7 +348,7 @@ td_api::object_ptr<td_api::chatBoostLevelFeatures> BoostManager::get_chat_boost_
|
|||||||
int32 level) const {
|
int32 level) const {
|
||||||
int32 actual_level =
|
int32 actual_level =
|
||||||
clamp(level, 0, static_cast<int32>(td_->option_manager_->get_option_integer("chat_boost_level_max")));
|
clamp(level, 0, static_cast<int32>(td_->option_manager_->get_option_integer("chat_boost_level_max")));
|
||||||
auto theme_counts = td_->theme_manager_->get_dialog_boost_available_count(actual_level);
|
auto theme_counts = td_->theme_manager_->get_dialog_boost_available_count(actual_level, false);
|
||||||
auto can_set_profile_background_custom_emoji =
|
auto can_set_profile_background_custom_emoji =
|
||||||
actual_level >= td_->option_manager_->get_option_integer("channel_profile_bg_icon_level_min");
|
actual_level >= td_->option_manager_->get_option_integer("channel_profile_bg_icon_level_min");
|
||||||
auto can_set_background_custom_emoji =
|
auto can_set_background_custom_emoji =
|
||||||
|
@ -213,10 +213,12 @@ void ThemeManager::ChatThemes::parse(ParserT &parser) {
|
|||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void ThemeManager::AccentColors::store(StorerT &storer) const {
|
void ThemeManager::AccentColors::store(StorerT &storer) const {
|
||||||
bool has_hash = hash_ != 0;
|
bool has_hash = hash_ != 0;
|
||||||
bool has_min_boost_levels = !min_boost_levels_.empty();
|
bool has_min_broadcast_boost_levels = !min_broadcast_boost_levels_.empty();
|
||||||
|
bool has_min_megagroup_boost_levels = !min_megagroup_boost_levels_.empty();
|
||||||
BEGIN_STORE_FLAGS();
|
BEGIN_STORE_FLAGS();
|
||||||
STORE_FLAG(has_hash);
|
STORE_FLAG(has_hash);
|
||||||
STORE_FLAG(has_min_boost_levels);
|
STORE_FLAG(has_min_broadcast_boost_levels);
|
||||||
|
STORE_FLAG(has_min_megagroup_boost_levels);
|
||||||
END_STORE_FLAGS();
|
END_STORE_FLAGS();
|
||||||
td::store(static_cast<int32>(light_colors_.size()), storer);
|
td::store(static_cast<int32>(light_colors_.size()), storer);
|
||||||
for (auto &it : light_colors_) {
|
for (auto &it : light_colors_) {
|
||||||
@ -232,18 +234,23 @@ void ThemeManager::AccentColors::store(StorerT &storer) const {
|
|||||||
if (has_hash) {
|
if (has_hash) {
|
||||||
td::store(hash_, storer);
|
td::store(hash_, storer);
|
||||||
}
|
}
|
||||||
if (has_min_boost_levels) {
|
if (has_min_broadcast_boost_levels) {
|
||||||
td::store(min_boost_levels_, storer);
|
td::store(min_broadcast_boost_levels_, storer);
|
||||||
|
}
|
||||||
|
if (has_min_megagroup_boost_levels) {
|
||||||
|
td::store(min_megagroup_boost_levels_, storer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
void ThemeManager::AccentColors::parse(ParserT &parser) {
|
void ThemeManager::AccentColors::parse(ParserT &parser) {
|
||||||
bool has_hash;
|
bool has_hash;
|
||||||
bool has_min_boost_levels;
|
bool has_min_broadcast_boost_levels;
|
||||||
|
bool has_min_megagroup_boost_levels;
|
||||||
BEGIN_PARSE_FLAGS();
|
BEGIN_PARSE_FLAGS();
|
||||||
PARSE_FLAG(has_hash);
|
PARSE_FLAG(has_hash);
|
||||||
PARSE_FLAG(has_min_boost_levels);
|
PARSE_FLAG(has_min_broadcast_boost_levels);
|
||||||
|
PARSE_FLAG(has_min_megagroup_boost_levels);
|
||||||
END_PARSE_FLAGS();
|
END_PARSE_FLAGS();
|
||||||
int32 size;
|
int32 size;
|
||||||
td::parse(size, parser);
|
td::parse(size, parser);
|
||||||
@ -268,11 +275,14 @@ void ThemeManager::AccentColors::parse(ParserT &parser) {
|
|||||||
if (has_hash) {
|
if (has_hash) {
|
||||||
td::parse(hash_, parser);
|
td::parse(hash_, parser);
|
||||||
}
|
}
|
||||||
if (has_min_boost_levels) {
|
if (has_min_broadcast_boost_levels) {
|
||||||
td::parse(min_boost_levels_, parser);
|
td::parse(min_broadcast_boost_levels_, parser);
|
||||||
} else {
|
} else {
|
||||||
hash_ = 0;
|
hash_ = 0;
|
||||||
}
|
}
|
||||||
|
if (has_min_megagroup_boost_levels) {
|
||||||
|
td::parse(min_megagroup_boost_levels_, parser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
@ -292,10 +302,12 @@ void ThemeManager::ProfileAccentColor::parse(ParserT &parser) {
|
|||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void ThemeManager::ProfileAccentColors::store(StorerT &storer) const {
|
void ThemeManager::ProfileAccentColors::store(StorerT &storer) const {
|
||||||
bool has_hash = hash_ != 0;
|
bool has_hash = hash_ != 0;
|
||||||
bool has_min_boost_levels = !min_boost_levels_.empty();
|
bool has_min_broadcast_boost_levels = !min_broadcast_boost_levels_.empty();
|
||||||
|
bool has_min_megagroup_boost_levels = !min_megagroup_boost_levels_.empty();
|
||||||
BEGIN_STORE_FLAGS();
|
BEGIN_STORE_FLAGS();
|
||||||
STORE_FLAG(has_hash);
|
STORE_FLAG(has_hash);
|
||||||
STORE_FLAG(has_min_boost_levels);
|
STORE_FLAG(has_min_broadcast_boost_levels);
|
||||||
|
STORE_FLAG(has_min_megagroup_boost_levels);
|
||||||
END_STORE_FLAGS();
|
END_STORE_FLAGS();
|
||||||
td::store(static_cast<int32>(light_colors_.size()), storer);
|
td::store(static_cast<int32>(light_colors_.size()), storer);
|
||||||
for (auto &it : light_colors_) {
|
for (auto &it : light_colors_) {
|
||||||
@ -311,18 +323,23 @@ void ThemeManager::ProfileAccentColors::store(StorerT &storer) const {
|
|||||||
if (has_hash) {
|
if (has_hash) {
|
||||||
td::store(hash_, storer);
|
td::store(hash_, storer);
|
||||||
}
|
}
|
||||||
if (has_min_boost_levels) {
|
if (has_min_broadcast_boost_levels) {
|
||||||
td::store(min_boost_levels_, storer);
|
td::store(min_broadcast_boost_levels_, storer);
|
||||||
|
}
|
||||||
|
if (has_min_megagroup_boost_levels) {
|
||||||
|
td::store(min_megagroup_boost_levels_, storer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
void ThemeManager::ProfileAccentColors::parse(ParserT &parser) {
|
void ThemeManager::ProfileAccentColors::parse(ParserT &parser) {
|
||||||
bool has_hash;
|
bool has_hash;
|
||||||
bool has_min_boost_levels;
|
bool has_min_broadcast_boost_levels;
|
||||||
|
bool has_min_megagroup_boost_levels;
|
||||||
BEGIN_PARSE_FLAGS();
|
BEGIN_PARSE_FLAGS();
|
||||||
PARSE_FLAG(has_hash);
|
PARSE_FLAG(has_hash);
|
||||||
PARSE_FLAG(has_min_boost_levels);
|
PARSE_FLAG(has_min_broadcast_boost_levels);
|
||||||
|
PARSE_FLAG(has_min_megagroup_boost_levels);
|
||||||
END_PARSE_FLAGS();
|
END_PARSE_FLAGS();
|
||||||
int32 size;
|
int32 size;
|
||||||
td::parse(size, parser);
|
td::parse(size, parser);
|
||||||
@ -347,8 +364,13 @@ void ThemeManager::ProfileAccentColors::parse(ParserT &parser) {
|
|||||||
if (has_hash) {
|
if (has_hash) {
|
||||||
td::parse(hash_, parser);
|
td::parse(hash_, parser);
|
||||||
}
|
}
|
||||||
if (has_min_boost_levels) {
|
if (has_min_broadcast_boost_levels) {
|
||||||
td::parse(min_boost_levels_, parser);
|
td::parse(min_broadcast_boost_levels_, parser);
|
||||||
|
} else {
|
||||||
|
hash_ = 0;
|
||||||
|
}
|
||||||
|
if (has_min_megagroup_boost_levels) {
|
||||||
|
td::parse(min_megagroup_boost_levels_, parser);
|
||||||
} else {
|
} else {
|
||||||
hash_ = 0;
|
hash_ = 0;
|
||||||
}
|
}
|
||||||
@ -433,13 +455,16 @@ void ThemeManager::tear_down() {
|
|||||||
parent_.reset();
|
parent_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeManager::DialogBoostAvailableCounts ThemeManager::get_dialog_boost_available_count(int32 level) {
|
ThemeManager::DialogBoostAvailableCounts ThemeManager::get_dialog_boost_available_count(int32 level,
|
||||||
|
bool for_megagroup) {
|
||||||
DialogBoostAvailableCounts result;
|
DialogBoostAvailableCounts result;
|
||||||
if (level >= td_->option_manager_->get_option_integer("channel_wallpaper_level_min")) {
|
if (level >= td_->option_manager_->get_option_integer("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());
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < accent_colors_.min_boost_levels_.size(); i++) {
|
auto &min_boost_levels =
|
||||||
if (level >= accent_colors_.min_boost_levels_[i]) {
|
for_megagroup ? accent_colors_.min_megagroup_boost_levels_ : accent_colors_.min_broadcast_boost_levels_;
|
||||||
|
for (size_t i = 0; i < min_boost_levels.size(); i++) {
|
||||||
|
if (level >= min_boost_levels[i]) {
|
||||||
result.accent_color_count_++;
|
result.accent_color_count_++;
|
||||||
|
|
||||||
if (accent_colors_.accent_color_ids_[i].is_built_in()) {
|
if (accent_colors_.accent_color_ids_[i].is_built_in()) {
|
||||||
@ -454,8 +479,10 @@ ThemeManager::DialogBoostAvailableCounts ThemeManager::get_dialog_boost_availabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < profile_accent_colors_.min_boost_levels_.size(); i++) {
|
auto &min_profile_boost_levels = for_megagroup ? profile_accent_colors_.min_megagroup_boost_levels_
|
||||||
if (level >= profile_accent_colors_.min_boost_levels_[i]) {
|
: profile_accent_colors_.min_broadcast_boost_levels_;
|
||||||
|
for (size_t i = 0; i < min_profile_boost_levels.size(); i++) {
|
||||||
|
if (level >= min_profile_boost_levels[i]) {
|
||||||
result.profile_accent_color_count_++;
|
result.profile_accent_color_count_++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -518,7 +545,9 @@ void ThemeManager::on_update_theme(telegram_api::object_ptr<telegram_api::theme>
|
|||||||
|
|
||||||
bool ThemeManager::on_update_accent_colors(FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> light_colors,
|
bool ThemeManager::on_update_accent_colors(FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> light_colors,
|
||||||
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> dark_colors,
|
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> dark_colors,
|
||||||
vector<AccentColorId> accent_color_ids, vector<int32> min_boost_levels) {
|
vector<AccentColorId> accent_color_ids,
|
||||||
|
vector<int32> min_broadcast_boost_levels,
|
||||||
|
vector<int32> min_megagroup_boost_levels) {
|
||||||
auto are_equal = [](const FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> &lhs,
|
auto are_equal = [](const FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> &lhs,
|
||||||
const FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> &rhs) {
|
const FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> &rhs) {
|
||||||
for (auto &lhs_it : lhs) {
|
for (auto &lhs_it : lhs) {
|
||||||
@ -529,7 +558,9 @@ bool ThemeManager::on_update_accent_colors(FlatHashMap<AccentColorId, vector<int
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
if (accent_color_ids == accent_colors_.accent_color_ids_ && min_boost_levels == accent_colors_.min_boost_levels_ &&
|
if (accent_color_ids == accent_colors_.accent_color_ids_ &&
|
||||||
|
min_broadcast_boost_levels == accent_colors_.min_broadcast_boost_levels_ &&
|
||||||
|
min_megagroup_boost_levels == accent_colors_.min_megagroup_boost_levels_ &&
|
||||||
are_equal(light_colors, accent_colors_.light_colors_) && are_equal(dark_colors, accent_colors_.dark_colors_)) {
|
are_equal(light_colors, accent_colors_.light_colors_) && are_equal(dark_colors, accent_colors_.dark_colors_)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -540,7 +571,8 @@ bool ThemeManager::on_update_accent_colors(FlatHashMap<AccentColorId, vector<int
|
|||||||
accent_colors_.dark_colors_[it.first] = std::move(it.second);
|
accent_colors_.dark_colors_[it.first] = std::move(it.second);
|
||||||
}
|
}
|
||||||
accent_colors_.accent_color_ids_ = std::move(accent_color_ids);
|
accent_colors_.accent_color_ids_ = std::move(accent_color_ids);
|
||||||
accent_colors_.min_boost_levels_ = std::move(min_boost_levels);
|
accent_colors_.min_broadcast_boost_levels_ = std::move(min_broadcast_boost_levels);
|
||||||
|
accent_colors_.min_megagroup_boost_levels_ = std::move(min_megagroup_boost_levels);
|
||||||
|
|
||||||
save_accent_colors();
|
save_accent_colors();
|
||||||
send_update_accent_colors();
|
send_update_accent_colors();
|
||||||
@ -550,7 +582,8 @@ bool ThemeManager::on_update_accent_colors(FlatHashMap<AccentColorId, vector<int
|
|||||||
bool ThemeManager::on_update_profile_accent_colors(
|
bool ThemeManager::on_update_profile_accent_colors(
|
||||||
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> light_colors,
|
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> light_colors,
|
||||||
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> dark_colors,
|
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> dark_colors,
|
||||||
vector<AccentColorId> accent_color_ids, vector<int32> min_boost_levels) {
|
vector<AccentColorId> accent_color_ids, vector<int32> min_broadcast_boost_levels,
|
||||||
|
vector<int32> min_megagroup_boost_levels) {
|
||||||
auto are_equal = [](const FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> &lhs,
|
auto are_equal = [](const FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> &lhs,
|
||||||
const FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> &rhs) {
|
const FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> &rhs) {
|
||||||
for (auto &lhs_it : lhs) {
|
for (auto &lhs_it : lhs) {
|
||||||
@ -562,7 +595,8 @@ bool ThemeManager::on_update_profile_accent_colors(
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
if (accent_color_ids == profile_accent_colors_.accent_color_ids_ &&
|
if (accent_color_ids == profile_accent_colors_.accent_color_ids_ &&
|
||||||
min_boost_levels == profile_accent_colors_.min_boost_levels_ &&
|
min_broadcast_boost_levels == profile_accent_colors_.min_broadcast_boost_levels_ &&
|
||||||
|
min_megagroup_boost_levels == profile_accent_colors_.min_megagroup_boost_levels_ &&
|
||||||
are_equal(light_colors, profile_accent_colors_.light_colors_) &&
|
are_equal(light_colors, profile_accent_colors_.light_colors_) &&
|
||||||
are_equal(dark_colors, profile_accent_colors_.dark_colors_)) {
|
are_equal(dark_colors, profile_accent_colors_.dark_colors_)) {
|
||||||
return false;
|
return false;
|
||||||
@ -574,7 +608,8 @@ bool ThemeManager::on_update_profile_accent_colors(
|
|||||||
profile_accent_colors_.dark_colors_[it.first] = std::move(it.second);
|
profile_accent_colors_.dark_colors_[it.first] = std::move(it.second);
|
||||||
}
|
}
|
||||||
profile_accent_colors_.accent_color_ids_ = std::move(accent_color_ids);
|
profile_accent_colors_.accent_color_ids_ = std::move(accent_color_ids);
|
||||||
profile_accent_colors_.min_boost_levels_ = std::move(min_boost_levels);
|
profile_accent_colors_.min_broadcast_boost_levels_ = std::move(min_broadcast_boost_levels);
|
||||||
|
profile_accent_colors_.min_megagroup_boost_levels_ = std::move(min_megagroup_boost_levels);
|
||||||
|
|
||||||
save_profile_accent_colors();
|
save_profile_accent_colors();
|
||||||
send_update_profile_accent_colors();
|
send_update_profile_accent_colors();
|
||||||
@ -702,10 +737,10 @@ td_api::object_ptr<td_api::updateAccentColors> ThemeManager::AccentColors::get_u
|
|||||||
return get_color_distance(lhs_color, rhs_color) + get_color_distance(lhs_color >> 8, rhs_color >> 8) +
|
return get_color_distance(lhs_color, rhs_color) + get_color_distance(lhs_color >> 8, rhs_color >> 8) +
|
||||||
get_color_distance(lhs_color >> 16, rhs_color >> 16);
|
get_color_distance(lhs_color >> 16, rhs_color >> 16);
|
||||||
};
|
};
|
||||||
FlatHashMap<AccentColorId, int32, AccentColorIdHash> min_boost_levels;
|
FlatHashMap<AccentColorId, int32, AccentColorIdHash> min_broadcast_boost_levels;
|
||||||
for (size_t i = 0; i < min_boost_levels_.size(); i++) {
|
for (size_t i = 0; i < min_broadcast_boost_levels_.size(); i++) {
|
||||||
CHECK(i < accent_color_ids_.size());
|
CHECK(i < accent_color_ids_.size());
|
||||||
min_boost_levels[accent_color_ids_[i]] = min_boost_levels_[i];
|
min_broadcast_boost_levels[accent_color_ids_[i]] = min_broadcast_boost_levels_[i];
|
||||||
}
|
}
|
||||||
for (auto &it : light_colors_) {
|
for (auto &it : light_colors_) {
|
||||||
auto light_colors = it.second;
|
auto light_colors = it.second;
|
||||||
@ -724,7 +759,8 @@ td_api::object_ptr<td_api::updateAccentColors> ThemeManager::AccentColors::get_u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
colors.push_back(td_api::make_object<td_api::accentColor>(it.first.get(), best_index, std::move(light_colors),
|
colors.push_back(td_api::make_object<td_api::accentColor>(it.first.get(), best_index, std::move(light_colors),
|
||||||
std::move(dark_colors), min_boost_levels[it.first]));
|
std::move(dark_colors),
|
||||||
|
min_broadcast_boost_levels[it.first]));
|
||||||
}
|
}
|
||||||
auto available_accent_color_ids =
|
auto available_accent_color_ids =
|
||||||
transform(accent_color_ids_, [](AccentColorId accent_color_id) { return accent_color_id.get(); });
|
transform(accent_color_ids_, [](AccentColorId accent_color_id) { return accent_color_id.get(); });
|
||||||
@ -748,10 +784,15 @@ td_api::object_ptr<td_api::profileAccentColors> ThemeManager::ProfileAccentColor
|
|||||||
|
|
||||||
td_api::object_ptr<td_api::updateProfileAccentColors>
|
td_api::object_ptr<td_api::updateProfileAccentColors>
|
||||||
ThemeManager::ProfileAccentColors::get_update_profile_accent_colors_object() const {
|
ThemeManager::ProfileAccentColors::get_update_profile_accent_colors_object() const {
|
||||||
FlatHashMap<AccentColorId, int32, AccentColorIdHash> min_boost_levels;
|
FlatHashMap<AccentColorId, int32, AccentColorIdHash> min_broadcast_boost_levels;
|
||||||
for (size_t i = 0; i < min_boost_levels_.size(); i++) {
|
for (size_t i = 0; i < min_broadcast_boost_levels_.size(); i++) {
|
||||||
CHECK(i < accent_color_ids_.size());
|
CHECK(i < accent_color_ids_.size());
|
||||||
min_boost_levels[accent_color_ids_[i]] = min_boost_levels_[i];
|
min_broadcast_boost_levels[accent_color_ids_[i]] = min_broadcast_boost_levels_[i];
|
||||||
|
}
|
||||||
|
FlatHashMap<AccentColorId, int32, AccentColorIdHash> min_megagroup_boost_levels;
|
||||||
|
for (size_t i = 0; i < min_megagroup_boost_levels_.size(); i++) {
|
||||||
|
CHECK(i < accent_color_ids_.size());
|
||||||
|
min_megagroup_boost_levels[accent_color_ids_[i]] = min_megagroup_boost_levels_[i];
|
||||||
}
|
}
|
||||||
vector<td_api::object_ptr<td_api::profileAccentColor>> colors;
|
vector<td_api::object_ptr<td_api::profileAccentColor>> colors;
|
||||||
for (auto &it : light_colors_) {
|
for (auto &it : light_colors_) {
|
||||||
@ -760,7 +801,8 @@ ThemeManager::ProfileAccentColors::get_update_profile_accent_colors_object() con
|
|||||||
auto dark_colors = dark_it != dark_colors_.end() ? dark_it->second.get_profile_accent_colors_object()
|
auto dark_colors = dark_it != dark_colors_.end() ? dark_it->second.get_profile_accent_colors_object()
|
||||||
: it.second.get_profile_accent_colors_object();
|
: it.second.get_profile_accent_colors_object();
|
||||||
colors.push_back(td_api::make_object<td_api::profileAccentColor>(
|
colors.push_back(td_api::make_object<td_api::profileAccentColor>(
|
||||||
it.first.get(), std::move(light_colors), std::move(dark_colors), min_boost_levels[it.first]));
|
it.first.get(), std::move(light_colors), std::move(dark_colors), min_megagroup_boost_levels[it.first],
|
||||||
|
min_broadcast_boost_levels[it.first]));
|
||||||
}
|
}
|
||||||
auto available_accent_color_ids =
|
auto available_accent_color_ids =
|
||||||
transform(accent_color_ids_, [](AccentColorId accent_color_id) { return accent_color_id.get(); });
|
transform(accent_color_ids_, [](AccentColorId accent_color_id) { return accent_color_id.get(); });
|
||||||
@ -895,7 +937,8 @@ void ThemeManager::on_get_accent_colors(Result<telegram_api::object_ptr<telegram
|
|||||||
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> light_colors;
|
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> light_colors;
|
||||||
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> dark_colors;
|
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> dark_colors;
|
||||||
vector<AccentColorId> accent_color_ids;
|
vector<AccentColorId> accent_color_ids;
|
||||||
vector<int32> min_boost_levels;
|
vector<int32> min_broadcast_boost_levels;
|
||||||
|
vector<int32> min_megagroup_boost_levels;
|
||||||
for (auto &option : peer_colors->colors_) {
|
for (auto &option : peer_colors->colors_) {
|
||||||
if ((option->colors_ != nullptr && option->colors_->get_id() != telegram_api::help_peerColorSet::ID) ||
|
if ((option->colors_ != nullptr && option->colors_->get_id() != telegram_api::help_peerColorSet::ID) ||
|
||||||
(option->dark_colors_ != nullptr && option->dark_colors_->get_id() != telegram_api::help_peerColorSet::ID)) {
|
(option->dark_colors_ != nullptr && option->dark_colors_->get_id() != telegram_api::help_peerColorSet::ID)) {
|
||||||
@ -932,7 +975,8 @@ void ThemeManager::on_get_accent_colors(Result<telegram_api::object_ptr<telegram
|
|||||||
}
|
}
|
||||||
if (!option->hidden_) {
|
if (!option->hidden_) {
|
||||||
accent_color_ids.push_back(accent_color_id);
|
accent_color_ids.push_back(accent_color_id);
|
||||||
min_boost_levels.push_back(max(0, option->channel_min_level_));
|
min_broadcast_boost_levels.push_back(max(0, option->channel_min_level_));
|
||||||
|
min_megagroup_boost_levels.push_back(max(0, option->group_min_level_));
|
||||||
}
|
}
|
||||||
if (!current_light_colors.empty()) {
|
if (!current_light_colors.empty()) {
|
||||||
light_colors[accent_color_id] = std::move(current_light_colors);
|
light_colors[accent_color_id] = std::move(current_light_colors);
|
||||||
@ -948,7 +992,7 @@ void ThemeManager::on_get_accent_colors(Result<telegram_api::object_ptr<telegram
|
|||||||
is_changed = true;
|
is_changed = true;
|
||||||
}
|
}
|
||||||
if (!on_update_accent_colors(std::move(light_colors), std::move(dark_colors), std::move(accent_color_ids),
|
if (!on_update_accent_colors(std::move(light_colors), std::move(dark_colors), std::move(accent_color_ids),
|
||||||
std::move(min_boost_levels)) &&
|
std::move(min_broadcast_boost_levels), std::move(min_megagroup_boost_levels)) &&
|
||||||
is_changed) {
|
is_changed) {
|
||||||
save_accent_colors();
|
save_accent_colors();
|
||||||
}
|
}
|
||||||
@ -991,7 +1035,8 @@ void ThemeManager::on_get_profile_accent_colors(
|
|||||||
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> light_colors;
|
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> light_colors;
|
||||||
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> dark_colors;
|
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> dark_colors;
|
||||||
vector<AccentColorId> accent_color_ids;
|
vector<AccentColorId> accent_color_ids;
|
||||||
vector<int32> min_boost_levels;
|
vector<int32> min_broadcast_boost_levels;
|
||||||
|
vector<int32> min_megagroup_boost_levels;
|
||||||
for (auto &option : peer_colors->colors_) {
|
for (auto &option : peer_colors->colors_) {
|
||||||
AccentColorId accent_color_id(option->color_id_);
|
AccentColorId accent_color_id(option->color_id_);
|
||||||
if (option->colors_ == nullptr || option->colors_->get_id() != telegram_api::help_peerColorProfileSet::ID ||
|
if (option->colors_ == nullptr || option->colors_->get_id() != telegram_api::help_peerColorProfileSet::ID ||
|
||||||
@ -1009,7 +1054,8 @@ void ThemeManager::on_get_profile_accent_colors(
|
|||||||
}
|
}
|
||||||
if (!option->hidden_) {
|
if (!option->hidden_) {
|
||||||
accent_color_ids.push_back(accent_color_id);
|
accent_color_ids.push_back(accent_color_id);
|
||||||
min_boost_levels.push_back(max(0, option->channel_min_level_));
|
min_broadcast_boost_levels.push_back(max(0, option->channel_min_level_));
|
||||||
|
min_megagroup_boost_levels.push_back(max(0, option->group_min_level_));
|
||||||
}
|
}
|
||||||
light_colors[accent_color_id] = std::move(current_light_color);
|
light_colors[accent_color_id] = std::move(current_light_color);
|
||||||
dark_colors[accent_color_id] = std::move(current_dark_color);
|
dark_colors[accent_color_id] = std::move(current_dark_color);
|
||||||
@ -1021,7 +1067,7 @@ void ThemeManager::on_get_profile_accent_colors(
|
|||||||
is_changed = true;
|
is_changed = true;
|
||||||
}
|
}
|
||||||
if (!on_update_profile_accent_colors(std::move(light_colors), std::move(dark_colors), std::move(accent_color_ids),
|
if (!on_update_profile_accent_colors(std::move(light_colors), std::move(dark_colors), std::move(accent_color_ids),
|
||||||
std::move(min_boost_levels)) &&
|
std::move(min_broadcast_boost_levels), std::move(min_megagroup_boost_levels)) &&
|
||||||
is_changed) {
|
is_changed) {
|
||||||
save_profile_accent_colors();
|
save_profile_accent_colors();
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class ThemeManager final : public Actor {
|
|||||||
int32 profile_accent_color_count_ = 0;
|
int32 profile_accent_color_count_ = 0;
|
||||||
int32 chat_theme_count_ = 0;
|
int32 chat_theme_count_ = 0;
|
||||||
};
|
};
|
||||||
DialogBoostAvailableCounts get_dialog_boost_available_count(int32 level);
|
DialogBoostAvailableCounts get_dialog_boost_available_count(int32 level, bool for_megagroup);
|
||||||
|
|
||||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||||
|
|
||||||
@ -105,7 +105,8 @@ class ThemeManager final : public Actor {
|
|||||||
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> light_colors_;
|
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> light_colors_;
|
||||||
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> dark_colors_;
|
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> dark_colors_;
|
||||||
vector<AccentColorId> accent_color_ids_;
|
vector<AccentColorId> accent_color_ids_;
|
||||||
vector<int32> min_boost_levels_;
|
vector<int32> min_broadcast_boost_levels_;
|
||||||
|
vector<int32> min_megagroup_boost_levels_;
|
||||||
int32 hash_ = 0;
|
int32 hash_ = 0;
|
||||||
|
|
||||||
td_api::object_ptr<td_api::updateAccentColors> get_update_accent_colors_object() const;
|
td_api::object_ptr<td_api::updateAccentColors> get_update_accent_colors_object() const;
|
||||||
@ -141,7 +142,8 @@ class ThemeManager final : public Actor {
|
|||||||
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> light_colors_;
|
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> light_colors_;
|
||||||
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> dark_colors_;
|
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> dark_colors_;
|
||||||
vector<AccentColorId> accent_color_ids_;
|
vector<AccentColorId> accent_color_ids_;
|
||||||
vector<int32> min_boost_levels_;
|
vector<int32> min_broadcast_boost_levels_;
|
||||||
|
vector<int32> min_megagroup_boost_levels_;
|
||||||
int32 hash_ = 0;
|
int32 hash_ = 0;
|
||||||
|
|
||||||
td_api::object_ptr<td_api::updateProfileAccentColors> get_update_profile_accent_colors_object() const;
|
td_api::object_ptr<td_api::updateProfileAccentColors> get_update_profile_accent_colors_object() const;
|
||||||
@ -169,13 +171,15 @@ class ThemeManager final : public Actor {
|
|||||||
|
|
||||||
bool on_update_accent_colors(FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> light_colors,
|
bool on_update_accent_colors(FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> light_colors,
|
||||||
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> dark_colors,
|
FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> dark_colors,
|
||||||
vector<AccentColorId> accent_color_ids, vector<int32> min_boost_levels);
|
vector<AccentColorId> accent_color_ids, vector<int32> min_broadcast_boost_levels,
|
||||||
|
vector<int32> min_megagroup_boost_levels);
|
||||||
|
|
||||||
void on_get_accent_colors(Result<telegram_api::object_ptr<telegram_api::help_PeerColors>> result);
|
void on_get_accent_colors(Result<telegram_api::object_ptr<telegram_api::help_PeerColors>> result);
|
||||||
|
|
||||||
bool on_update_profile_accent_colors(FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> light_colors,
|
bool on_update_profile_accent_colors(FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> light_colors,
|
||||||
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> dark_colors,
|
FlatHashMap<AccentColorId, ProfileAccentColor, AccentColorIdHash> dark_colors,
|
||||||
vector<AccentColorId> accent_color_ids, vector<int32> min_boost_levels);
|
vector<AccentColorId> accent_color_ids, vector<int32> min_broadcast_boost_levels,
|
||||||
|
vector<int32> min_megagroup_boost_levels);
|
||||||
|
|
||||||
ProfileAccentColor get_profile_accent_color(
|
ProfileAccentColor get_profile_accent_color(
|
||||||
telegram_api::object_ptr<telegram_api::help_PeerColorSet> &&color_set) const;
|
telegram_api::object_ptr<telegram_api::help_PeerColorSet> &&color_set) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user