Don't try to reload data mutiple times without network.

This commit is contained in:
levlam 2023-02-06 20:31:17 +03:00
parent d4833b7844
commit 1e6c3ef93d
2 changed files with 19 additions and 3 deletions

View File

@ -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<td_api::object_ptr<td_api::chats>>) {
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) {

View File

@ -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<int32> get_update_ids(const telegram_api::Updates *updates_ptr);