diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 3774ef32e..bed2121e1 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -1877,12 +1877,16 @@ void UpdatesManager::try_reload_data() { schedule_data_reload(); return; } - next_data_reload_time_ = now + Random::fast(3000, 4200); + next_data_reload_time_ = now + 365 * 86400; + + auto promise = PromiseCreator::lambda([actor_id = actor_id(this)](Result>) { + send_closure(actor_id, &UpdatesManager::on_data_reloaded); + }); LOG(INFO) << "Reload data"; - td_->animations_manager_->get_saved_animations(Auto()); + td_->animations_manager_->reload_saved_animations(true); td_->autosave_manager_->reload_autosave_settings(); - td_->contacts_manager_->reload_created_public_dialogs(PublicDialogType::HasUsername, Auto()); + td_->contacts_manager_->reload_created_public_dialogs(PublicDialogType::HasUsername, std::move(promise)); td_->contacts_manager_->reload_created_public_dialogs(PublicDialogType::IsLocationBased, Auto()); get_default_emoji_statuses(td_, Auto()); td_->notification_settings_manager_->reload_saved_ringtones(Auto()); @@ -1915,6 +1919,16 @@ void UpdatesManager::try_reload_data() { schedule_data_reload(); } +void UpdatesManager::on_data_reloaded() { + if (G()->close_flag()) { + return; + } + + next_data_reload_time_ = Time::now() + Random::fast(3000, 4200); + data_reload_timeout_.cancel_timeout(); + schedule_data_reload(); +} + void UpdatesManager::subscribe_to_transcribed_audio_updates(int64 transcription_id, TranscribedAudioHandler on_update) { CHECK(transcription_id != 0); if (pending_audio_transcriptions_.count(transcription_id) != 0) { diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index f3c4af8e9..424c2ea48 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -379,6 +379,8 @@ class UpdatesManager final : public Actor { void try_reload_data(); + void on_data_reloaded(); + uint64 get_most_unused_auth_key_id(); static vector get_update_ids(const telegram_api::Updates *updates_ptr);