From ef7914a26d814b876022632dec26ce2e4244b00f Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 9 Jan 2019 05:13:03 +0300 Subject: [PATCH] Delay notifications in the open chat for 1 second. GitOrigin-RevId: 9162b726f404b5116fd64a4894bb16a76e1c1aea --- td/telegram/MessagesManager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 8b09bf7f..a8b13f47 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -18352,8 +18352,12 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f } VLOG(notifications) << "Create " << m->notification_id << " with " << m->message_id << " in " << group_info.group_id << '/' << d->dialog_id; - int32 min_delay_ms = - need_delay_message_content_notification(m->content.get(), td_->contacts_manager_->get_my_id()) ? 3000 : 0; + int32 min_delay_ms = 0; + if (need_delay_message_content_notification(m->content.get(), td_->contacts_manager_->get_my_id())) { + min_delay_ms = 3000; // 3 seconds + } else if (td_->is_online() && d->is_opened) { + min_delay_ms = 1000; // 1 second + } send_closure_later(G()->notification_manager(), &NotificationManager::add_notification, notification_group_id, from_mentions ? NotificationGroupType::Mentions : NotificationGroupType::Messages, d->dialog_id, m->date, settings_dialog_id, m->disable_notification, min_delay_ms, m->notification_id,