diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 5572374b..1bd57b99 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2671,6 +2671,9 @@ updateFavoriteStickers sticker_ids:vector = Update; //@description The list of saved animations was updated @animation_ids The new list of file identifiers of saved animations updateSavedAnimations animation_ids:vector = 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 = Update; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index aece15ae..edafa414 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/BackgroundManager.cpp b/td/telegram/BackgroundManager.cpp index 05e672fe..8af3761f 100644 --- a/td/telegram/BackgroundManager.cpp +++ b/td/telegram/BackgroundManager.cpp @@ -205,30 +205,40 @@ class BackgroundManager::BackgroundLogEvent { template 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); - storer.context()->td().get_actor_unsafe()->documents_manager_->store_document(file_id_, 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 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); - file_id_ = parser.context()->td().get_actor_unsafe()->documents_manager_->parse_document(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 BackgroundManager::get_update_selected_background() const { + return td_api::make_object(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 BackgroundManager::prepare_input_file(const tl_object_ptr &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 &&promise) { diff --git a/td/telegram/BackgroundManager.h b/td/telegram/BackgroundManager.h index ef4c307d..d3e81547 100644 --- a/td/telegram/BackgroundManager.h +++ b/td/telegram/BackgroundManager.h @@ -87,6 +87,10 @@ class BackgroundManager : public Actor { telegram_api::object_ptr &&input_wallpaper, Promise &&promise) const; + td_api::object_ptr get_update_selected_background() const; + + void send_update_selected_background() const; + BackgroundId add_solid_background(int32 color); Background *add_background(BackgroundId background_id);