From 035cec9fb9eaae1fed5355331bd2af5ce22c10a2 Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 6 Aug 2022 13:54:10 +0300 Subject: [PATCH] Simplify changing file sources. --- td/telegram/ContactsManager.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 4a76a5c01..c13f4d9dc 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -10580,13 +10580,8 @@ void ContactsManager::update_user_full(UserFull *user_full, UserId user_id, cons } } - for (auto &file_id : user_full->registered_file_ids) { - td_->file_manager_->remove_file_source(file_id, file_source_id); - } + td_->file_manager_->change_files_source(file_source_id, user_full->registered_file_ids, file_ids); user_full->registered_file_ids = std::move(file_ids); - for (auto &file_id : user_full->registered_file_ids) { - td_->file_manager_->add_file_source(file_id, file_source_id); - } } } @@ -12964,13 +12959,8 @@ void ContactsManager::on_update_chat_full_photo(ChatFull *chat_full, ChatId chat } } - for (auto &file_id : chat_full->registered_photo_file_ids) { - td_->file_manager_->remove_file_source(file_id, file_source_id); - } + td_->file_manager_->change_files_source(file_source_id, chat_full->registered_photo_file_ids, photo_file_ids); chat_full->registered_photo_file_ids = std::move(photo_file_ids); - for (auto &file_id : chat_full->registered_photo_file_ids) { - td_->file_manager_->add_file_source(file_id, file_source_id); - } } void ContactsManager::on_update_channel_full_photo(ChannelFull *channel_full, ChannelId channel_id, Photo photo) { @@ -12997,13 +12987,8 @@ void ContactsManager::on_update_channel_full_photo(ChannelFull *channel_full, Ch } } - for (auto &file_id : channel_full->registered_photo_file_ids) { - td_->file_manager_->remove_file_source(file_id, file_source_id); - } + td_->file_manager_->change_files_source(file_source_id, channel_full->registered_photo_file_ids, photo_file_ids); channel_full->registered_photo_file_ids = std::move(photo_file_ids); - for (auto &file_id : channel_full->registered_photo_file_ids) { - td_->file_manager_->add_file_source(file_id, file_source_id); - } } void ContactsManager::on_get_permanent_dialog_invite_link(DialogId dialog_id, const DialogInviteLink &invite_link) {