Support td_api::updateSelectedBackground in getCurrentState.

GitOrigin-RevId: 06352042ba464af8fc66101e53f51e905dadbd3b
This commit is contained in:
levlam 2019-05-10 19:04:14 +03:00
parent 57e0b917b8
commit db2ac0ed98
3 changed files with 16 additions and 3 deletions

View File

@ -9,6 +9,7 @@
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/BackgroundType.hpp"
#include "td/telegram/ConfigShared.h"
#include "td/telegram/DialogId.h"
@ -383,12 +384,12 @@ BackgroundId BackgroundManager::search_background(const string &name, Promise<Un
return BackgroundId();
}
td_api::object_ptr<td_api::updateSelectedBackground> BackgroundManager::get_update_selected_background() const {
td_api::object_ptr<td_api::updateSelectedBackground> BackgroundManager::get_update_selected_background_object() 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());
send_closure(G()->td(), &Td::send_update, get_update_selected_background_object());
}
Result<FileId> BackgroundManager::prepare_input_file(const tl_object_ptr<td_api::InputFile> &input_file) {
@ -794,4 +795,12 @@ FileSourceId BackgroundManager::get_background_file_source_id(BackgroundId backg
return result.second;
}
void BackgroundManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
if (td_->auth_manager_->is_bot()) {
return;
}
updates.push_back(get_update_selected_background_object());
}
} // namespace td

View File

@ -58,6 +58,8 @@ class BackgroundManager : public Actor {
telegram_api::object_ptr<telegram_api::wallPaper> wallpaper,
Promise<Unit> &&promise);
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
private:
struct Background {
BackgroundId id;
@ -87,7 +89,7 @@ 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;
td_api::object_ptr<td_api::updateSelectedBackground> get_update_selected_background_object() const;
void send_update_selected_background() const;

View File

@ -4729,6 +4729,8 @@ void Td::on_request(uint64 id, const td_api::getCurrentState &request) {
if (auth_manager_->is_authorized()) {
contacts_manager_->get_current_state(updates);
background_manager_->get_current_state(updates);
animations_manager_->get_current_state(updates);
stickers_manager_->get_current_state(updates);