From 5807434c8cb6a66e269ffd2f4e7acf677b8c6c87 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 6 Aug 2024 12:30:37 +0300 Subject: [PATCH] Schedule next processing of viewed messages only if the user is online. --- td/telegram/MessagesManager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index bef6a3450..e8e829e5c 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -12051,9 +12051,10 @@ void MessagesManager::process_viewed_message(Dialog *d, const vector if (!extended_media_message_ids.empty()) { td_->create_handler()->send(dialog_id, std::move(extended_media_message_ids)); } - - int divisor = 5 - min(max(G()->unix_time() - newest_message_date, 0) / UPDATE_VIEWED_MESSAGES_PERIOD, 4); - update_viewed_messages_timeout_.add_timeout_in(dialog_id.get(), UPDATE_VIEWED_MESSAGES_PERIOD / divisor); + if (td_->online_manager_->is_online()) { + int divisor = 5 - min(max(G()->unix_time() - newest_message_date, 0) / UPDATE_VIEWED_MESSAGES_PERIOD, 4); + update_viewed_messages_timeout_.add_timeout_in(dialog_id.get(), UPDATE_VIEWED_MESSAGES_PERIOD / divisor); + } } void MessagesManager::on_send_update_chat_read_inbox_timeout(DialogId dialog_id) {