From e1812c653119d4ac77569d9f1cb5c68f8fc63a49 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 20 Sep 2018 22:38:19 +0300 Subject: [PATCH] Add AnimationsManager::get_current_state. GitOrigin-RevId: 77349703eb55cf61b13941dba7bd513068c8519c --- td/telegram/AnimationsManager.cpp | 18 ++++++++++++------ td/telegram/AnimationsManager.h | 4 ++++ td/telegram/Td.cpp | 26 +++++++++++++++----------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/td/telegram/AnimationsManager.cpp b/td/telegram/AnimationsManager.cpp index bc3e5f6e7..a816d9b00 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 8f3312375..73d93e7db 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 a443624d9..57b18c122 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)));