Support AccentColor in MinChannel.
This commit is contained in:
parent
24c84398ee
commit
43e210dbc8
@ -5788,7 +5788,14 @@ AccentColorId ContactsManager::get_chat_accent_color_id(ChatId chat_id) const {
|
||||
|
||||
AccentColorId ContactsManager::get_channel_accent_color_id(ChannelId channel_id) const {
|
||||
auto c = get_channel(channel_id);
|
||||
if (c == nullptr || !c->accent_color_id.is_valid()) {
|
||||
if (c == nullptr) {
|
||||
auto min_channel = get_min_channel(channel_id);
|
||||
if (min_channel != nullptr && min_channel->accent_color_id_.is_valid()) {
|
||||
return min_channel->accent_color_id_;
|
||||
}
|
||||
return AccentColorId(channel_id);
|
||||
}
|
||||
if (!c->accent_color_id.is_valid()) {
|
||||
return AccentColorId(channel_id);
|
||||
}
|
||||
|
||||
@ -19118,6 +19125,9 @@ void ContactsManager::on_get_channel(telegram_api::channel &channel, const char
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
min_channel->photo_.minithumbnail.clear();
|
||||
}
|
||||
if ((channel.flags2_ & telegram_api::channel::COLOR_MASK) != 0) {
|
||||
min_channel->accent_color_id_ = AccentColorId(channel.color_);
|
||||
}
|
||||
min_channel->title_ = std::move(channel.title_);
|
||||
min_channel->is_megagroup_ = is_megagroup;
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/AccentColorId.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
@ -15,6 +16,7 @@ namespace td {
|
||||
struct MinChannel {
|
||||
string title_;
|
||||
DialogPhoto photo_;
|
||||
AccentColorId accent_color_id_;
|
||||
bool is_megagroup_ = false;
|
||||
};
|
||||
|
||||
|
@ -18,10 +18,12 @@ template <class StorerT>
|
||||
void store(const MinChannel &min_channel, StorerT &storer) {
|
||||
bool has_title = !min_channel.title_.empty();
|
||||
bool has_photo = min_channel.photo_.small_file_id.is_valid();
|
||||
bool has_accent_color_id = min_channel.accent_color_id_.is_valid();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_title);
|
||||
STORE_FLAG(has_photo);
|
||||
STORE_FLAG(min_channel.is_megagroup_);
|
||||
STORE_FLAG(has_accent_color_id);
|
||||
END_STORE_FLAGS();
|
||||
if (has_title) {
|
||||
store(min_channel.title_, storer);
|
||||
@ -29,16 +31,21 @@ void store(const MinChannel &min_channel, StorerT &storer) {
|
||||
if (has_photo) {
|
||||
store(min_channel.photo_, storer);
|
||||
}
|
||||
if (has_accent_color_id) {
|
||||
store(min_channel.accent_color_id_, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(MinChannel &min_channel, ParserT &parser) {
|
||||
bool has_title;
|
||||
bool has_photo;
|
||||
bool has_accent_color_id;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_title);
|
||||
PARSE_FLAG(has_photo);
|
||||
PARSE_FLAG(min_channel.is_megagroup_);
|
||||
PARSE_FLAG(has_accent_color_id);
|
||||
END_PARSE_FLAGS();
|
||||
if (has_title) {
|
||||
parse(min_channel.title_, parser);
|
||||
@ -46,6 +53,9 @@ void parse(MinChannel &min_channel, ParserT &parser) {
|
||||
if (has_photo) {
|
||||
parse(min_channel.photo_, parser);
|
||||
}
|
||||
if (has_accent_color_id) {
|
||||
parse(min_channel.accent_color_id_, parser);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
Loading…
Reference in New Issue
Block a user