From bcb7a9f6d20bbaade3dd10a007e499f072691007 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 3 May 2019 23:36:01 +0300 Subject: [PATCH] Fix total_count in SecretChat notification group after notification removal. GitOrigin-RevId: 7bedbb220b3e5e59e3c6c293db9bed6819c01128 --- td/telegram/NotificationManager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 8e0a2444..4e0a71d7 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -1857,9 +1857,10 @@ void NotificationManager::remove_notification(NotificationGroupId group_id, Noti } } + bool have_all_notifications = group_it->second.type == NotificationGroupType::Calls || + group_it->second.type == NotificationGroupType::SecretChat; bool is_total_count_changed = false; - if ((group_it->second.type != NotificationGroupType::Calls && is_permanent) || - (group_it->second.type == NotificationGroupType::Calls && is_found)) { + if ((!have_all_notifications && is_permanent) || (have_all_notifications && is_found)) { if (group_it->second.total_count == 0) { LOG(ERROR) << "Total notification count became negative in " << group_id << " after removing " << notification_id; } else { @@ -2025,7 +2026,8 @@ void NotificationManager::remove_notification_group(NotificationGroupId group_id group_it->second.notifications.erase(group_it->second.notifications.begin(), group_it->second.notifications.begin() + notification_delete_end); } - if (group_it->second.type == NotificationGroupType::Calls) { + if (group_it->second.type == NotificationGroupType::Calls || + group_it->second.type == NotificationGroupType::SecretChat) { new_total_count = static_cast(group_it->second.notifications.size()); } if (group_it->second.total_count == new_total_count) {