Add updateSelectedBackground.

GitOrigin-RevId: 78ca327ff6da27da19fc6a05e2354af969b42bfb
This commit is contained in:
levlam 2019-05-10 18:55:55 +03:00
parent 2366eb9b9b
commit 57e0b917b8
4 changed files with 30 additions and 2 deletions

View File

@ -2671,6 +2671,9 @@ updateFavoriteStickers sticker_ids:vector<int32> = Update;
//@description The list of saved animations was updated @animation_ids The new list of file identifiers of saved animations
updateSavedAnimations animation_ids:vector<int32> = Update;
//@description The selected background has changed @background The new selected background; may be null
updateSelectedBackground background:background = Update;
//@description Some language pack strings have been updated @localization_target Localization target to which the language pack belongs @language_pack_id Identifier of the updated language pack @strings List of changed language pack strings
updateLanguagePackStrings localization_target:string language_pack_id:string strings:vector<languagePackString> = Update;

Binary file not shown.

View File

@ -205,30 +205,40 @@ class BackgroundManager::BackgroundLogEvent {
template <class StorerT>
void store(StorerT &storer) const {
bool has_file_id = file_id_.is_valid();
BEGIN_STORE_FLAGS();
STORE_FLAG(is_creator_);
STORE_FLAG(is_default_);
STORE_FLAG(is_dark_);
STORE_FLAG(has_file_id);
END_STORE_FLAGS();
td::store(background_id_, storer);
td::store(access_hash_, storer);
td::store(name_, storer);
if (has_file_id) {
storer.context()->td().get_actor_unsafe()->documents_manager_->store_document(file_id_, storer);
}
td::store(type_, storer);
td::store(set_type_, storer);
}
template <class ParserT>
void parse(ParserT &parser) {
bool has_file_id;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_creator_);
PARSE_FLAG(is_default_);
PARSE_FLAG(is_dark_);
PARSE_FLAG(has_file_id);
END_PARSE_FLAGS();
td::parse(background_id_, parser);
td::parse(access_hash_, parser);
td::parse(name_, parser);
if (has_file_id) {
file_id_ = parser.context()->td().get_actor_unsafe()->documents_manager_->parse_document(parser);
} else {
file_id_ = FileId();
}
td::parse(type_, parser);
td::parse(set_type_, parser);
}
@ -266,6 +276,8 @@ void BackgroundManager::start_up() {
file_id_to_background_id_.emplace(background->file_id, background->id);
}
}
send_update_selected_background();
}
void BackgroundManager::tear_down() {
@ -371,6 +383,14 @@ BackgroundId BackgroundManager::search_background(const string &name, Promise<Un
return BackgroundId();
}
td_api::object_ptr<td_api::updateSelectedBackground> BackgroundManager::get_update_selected_background() const {
return td_api::make_object<td_api::updateSelectedBackground>(get_background_object(set_background_id_));
}
void BackgroundManager::send_update_selected_background() const {
send_closure(G()->td(), &Td::send_update, get_update_selected_background());
}
Result<FileId> BackgroundManager::prepare_input_file(const tl_object_ptr<td_api::InputFile> &input_file) {
auto r_file_id = td_->file_manager_->get_input_file_id(FileType::Background, input_file, {}, false, false);
if (r_file_id.is_error()) {
@ -506,6 +526,7 @@ void BackgroundManager::set_background_id(BackgroundId background_id, const Back
set_background_type_ = type;
save_background_id();
send_update_selected_background();
}
void BackgroundManager::upload_background_file(FileId file_id, const BackgroundType &type, Promise<Unit> &&promise) {

View File

@ -87,6 +87,10 @@ class BackgroundManager : public Actor {
telegram_api::object_ptr<telegram_api::InputWallPaper> &&input_wallpaper,
Promise<Unit> &&promise) const;
td_api::object_ptr<td_api::updateSelectedBackground> get_update_selected_background() const;
void send_update_selected_background() const;
BackgroundId add_solid_background(int32 color);
Background *add_background(BackgroundId background_id);