From 36d45046d00a94dc8bebac257943801fedb97f7b Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 21 Jan 2019 23:30:28 +0300 Subject: [PATCH] Create saved animations file source. GitOrigin-RevId: 0022034837c77740e335b99c5dc008a6802c7ea6 --- td/telegram/AnimationsManager.cpp | 16 ++++++++++++++++ td/telegram/AnimationsManager.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/td/telegram/AnimationsManager.cpp b/td/telegram/AnimationsManager.cpp index f8f3bb42..467ebe0d 100644 --- a/td/telegram/AnimationsManager.cpp +++ b/td/telegram/AnimationsManager.cpp @@ -9,6 +9,7 @@ #include "td/telegram/AuthManager.h" #include "td/telegram/DialogId.h" #include "td/telegram/DocumentsManager.h" +#include "td/telegram/FileReferenceManager.h" #include "td/telegram/files/FileManager.h" #include "td/telegram/files/FileType.h" #include "td/telegram/Global.h" @@ -661,6 +662,7 @@ bool AnimationsManager::add_saved_animation_impl(FileId animation_id, Promise AnimationsManager::get_update_ void AnimationsManager::send_update_saved_animations(bool from_database) { if (are_saved_animations_loaded_) { + if (!saved_animations_file_source_id_.is_valid() && !saved_animation_ids_.empty()) { + saved_animations_file_source_id_ = td_->file_reference_manager_->create_saved_animations_file_source(); + } + for (auto &animation_id : saved_animation_ids_) { + td_->file_manager_->add_file_source(animation_id, saved_animations_file_source_id_); + auto thumbnail_file_id = get_animation_thumbnail_file_id(animation_id); + if (thumbnail_file_id.is_valid()) { + td_->file_manager_->add_file_source(thumbnail_file_id, saved_animations_file_source_id_); + } + } + // there is no much reason to delete source from deleted saved animations, + // it will be automatically deleted after unsuccessfull try of file reference repairing + // moreover one thumbnail can belong to different animations, so removal should be careful + send_closure(G()->td(), &Td::send_update, get_update_saved_animations_object()); if (!from_database) { diff --git a/td/telegram/AnimationsManager.h b/td/telegram/AnimationsManager.h index 6dde7dab..1791a4fc 100644 --- a/td/telegram/AnimationsManager.h +++ b/td/telegram/AnimationsManager.h @@ -13,6 +13,7 @@ #include "td/actor/PromiseFuture.h" #include "td/telegram/files/FileId.h" +#include "td/telegram/files/FileSourceId.h" #include "td/telegram/Photo.h" #include "td/telegram/SecretInputMedia.h" @@ -136,6 +137,7 @@ class AnimationsManager : public Actor { bool are_saved_animations_loaded_ = false; vector> load_saved_animations_queries_; vector> reload_saved_animations_queries_; + FileSourceId saved_animations_file_source_id_; }; } // namespace td