diff --git a/td/telegram/AnimationsManager.cpp b/td/telegram/AnimationsManager.cpp index bc3e5f6e..a816d9b0 100644 --- a/td/telegram/AnimationsManager.cpp +++ b/td/telegram/AnimationsManager.cpp @@ -665,14 +665,14 @@ void AnimationsManager::remove_saved_animation(const tl_object_ptr AnimationsManager::get_update_saved_animatoions_object() const { + return td_api::make_object( + transform(saved_animation_ids_, [](FileId animation_id) { return animation_id.get(); })); +} + void AnimationsManager::send_update_saved_animations(bool from_database) { if (are_saved_animations_loaded_) { - vector animations; - animations.reserve(saved_animation_ids_.size()); - for (auto animation_id : saved_animation_ids_) { - animations.push_back(animation_id.get()); - } - send_closure(G()->td(), &Td::send_update, make_tl_object(std::move(animations))); + send_closure(G()->td(), &Td::send_update, get_update_saved_animatoions_object()); if (!from_database) { save_saved_animations_to_database(); @@ -694,4 +694,10 @@ string AnimationsManager::get_animation_search_text(FileId file_id) const { return animation->file_name; } +void AnimationsManager::get_current_state(vector> &updates) const { + if (are_saved_animations_loaded_) { + updates.push_back(get_update_saved_animatoions_object()); + } +} + } // namespace td diff --git a/td/telegram/AnimationsManager.h b/td/telegram/AnimationsManager.h index 8f331237..73d93e7d 100644 --- a/td/telegram/AnimationsManager.h +++ b/td/telegram/AnimationsManager.h @@ -81,6 +81,8 @@ class AnimationsManager : public Actor { string get_animation_search_text(FileId file_id) const; + void get_current_state(vector> &updates) const; + private: class Animation { public: @@ -111,6 +113,8 @@ class AnimationsManager : public Actor { void on_load_saved_animations_finished(vector &&saved_animation_ids, bool from_database = false); + td_api::object_ptr get_update_saved_animatoions_object() const; + void send_update_saved_animations(bool from_database = false); void save_saved_animations_to_database(); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index a443624d..57b18c12 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -4587,19 +4587,23 @@ void Td::on_request(uint64 id, const td_api::getCurrentState &request) { updates.push_back(td_api::make_object(get_connection_state_object(connection_state_))); - contacts_manager_->get_current_state(updates); + if (auth_manager_->is_authorized()) { + contacts_manager_->get_current_state(updates); - stickers_manager_->get_current_state(updates); + animations_manager_->get_current_state(updates); - /* - // TODO - updateUnreadMessageCount { - updateUnreadChatCount { - updateScopeNotificationSettings { - updateScopeNotificationSettings { - updateNewChat { - updateChatLastMessage { - */ + stickers_manager_->get_current_state(updates); + + /* + // TODO + updateUnreadMessageCount { + updateUnreadChatCount { + updateScopeNotificationSettings { + updateScopeNotificationSettings { + updateNewChat { + updateChatLastMessage { + */ + } // send response synchronously to prevent "Request aborted" or other changes of the current state send_result(id, td_api::make_object(std::move(updates)));