From 989dc3d8a6fc05aa9d7a794c91cdcffd7cf2f13c Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 26 Aug 2023 02:14:00 +0300 Subject: [PATCH] Fix removal of notifications from pending updates. --- td/telegram/NotificationManager.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index d66033a87..cd4a8de13 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -2136,9 +2136,17 @@ void NotificationManager::remove_notification_group(NotificationGroupId group_id } else { remove_added_notifications_from_pending_updates( group_id, [max_object_id](const td_api::object_ptr ¬ification) { - return notification->type_->get_id() == td_api::notificationTypeNewMessage::ID && - static_cast(notification->type_.get())->message_->id_ <= + const auto *type = notification->type_.get(); + switch (type->get_id()) { + case td_api::notificationTypeNewMessage::ID: + return static_cast(type)->message_->id_ <= max_object_id.get(); + case td_api::notificationTypeNewPushMessage::ID: + return static_cast(type)->message_id_ <= + max_object_id.get(); + default: + return false; + } }); } @@ -2235,10 +2243,16 @@ void NotificationManager::remove_temporary_notifications(NotificationGroupId gro on_notifications_removed(std::move(group_it), std::move(added_notifications), std::move(removed_notification_ids), false); - remove_added_notifications_from_pending_updates( - group_id, [](const td_api::object_ptr ¬ification) { - return notification->get_id() == td_api::notificationTypeNewPushMessage::ID; - }); + remove_added_notifications_from_pending_updates(group_id, + [](const td_api::object_ptr ¬ification) { + const auto *type = notification->type_.get(); + switch (type->get_id()) { + case td_api::notificationTypeNewPushMessage::ID: + return true; + default: + return false; + } + }); } int32 NotificationManager::get_temporary_notification_total_count(const NotificationGroup &group) {