Fix forcing updates in remove_notification_group after removal of temporary notifications.

GitOrigin-RevId: 93cc36bc85eb5f2ac5ec9e98a3766408f967544d
This commit is contained in:
levlam 2019-04-10 23:54:03 +03:00
parent 009c78ce5b
commit 88788b2460
3 changed files with 15 additions and 10 deletions

View File

@ -19253,11 +19253,11 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f
if (!force) {
if (d->message_notification_group.group_id.is_valid()) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notifications,
d->message_notification_group.group_id);
d->message_notification_group.group_id, "add_new_message_notification 1");
}
if (d->mention_notification_group.group_id.is_valid()) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notifications,
d->mention_notification_group.group_id);
d->mention_notification_group.group_id, "add_new_message_notification 2");
}
}

View File

@ -850,7 +850,7 @@ void NotificationManager::add_notification(NotificationGroupId group_id, Notific
<< (is_silent ? " silently" : " with sound") << ": " << *type;
if (!type->is_temporary()) {
remove_temporary_notifications(group_id);
remove_temporary_notifications(group_id, "add_notification");
}
auto group_it = get_group_force(group_id);
@ -1929,7 +1929,7 @@ void NotificationManager::remove_notification_group(NotificationGroupId group_id
}
if (new_total_count == 0) {
remove_temporary_notifications(group_id);
remove_temporary_notifications(group_id, "remove_notification_group");
}
VLOG(notifications) << "Remove " << group_id << " up to " << max_notification_id << " or " << max_message_id
@ -2020,8 +2020,11 @@ void NotificationManager::remove_notification_group(NotificationGroupId group_id
on_notifications_removed(std::move(group_it), vector<td_api::object_ptr<td_api::notification>>(),
std::move(removed_notification_ids), force_update);
} else {
VLOG(notifications) << "Have new_total_count = " << new_total_count << " and " << removed_notification_ids.size()
<< " removed notifications";
VLOG(notifications) << "Have new_total_count = " << new_total_count << ", " << removed_notification_ids.size()
<< " removed notifications and force_update = " << force_update;
if (force_update) {
force_flush_pending_updates(group_id, "remove_notification_group");
}
}
if (max_notification_id.is_valid()) {
@ -2041,7 +2044,7 @@ void NotificationManager::remove_notification_group(NotificationGroupId group_id
promise.set_value(Unit());
}
void NotificationManager::remove_temporary_notifications(NotificationGroupId group_id) {
void NotificationManager::remove_temporary_notifications(NotificationGroupId group_id, const char *source) {
CHECK(group_id.is_valid());
if (is_disabled() || max_notification_group_count_ == 0) {
@ -2057,6 +2060,8 @@ void NotificationManager::remove_temporary_notifications(NotificationGroupId gro
return;
}
VLOG(notifications) << "Remove temporary notifications in " << group_id << " from " << source;
auto &group = group_it->second;
while (!group.pending_notifications.empty() && group.pending_notifications.back().type->is_temporary()) {
VLOG(notifications) << "Remove temporary " << group.pending_notifications.back() << " from " << group_id;
@ -3792,7 +3797,7 @@ void NotificationManager::after_get_difference_impl() {
}
}
for (auto group_id : reversed(to_remove_temporary_notifications_group_ids)) {
remove_temporary_notifications(group_id);
remove_temporary_notifications(group_id, "after_get_difference");
}
flush_all_pending_updates(false, "after_get_difference");
@ -3831,7 +3836,7 @@ void NotificationManager::after_get_chat_difference_impl(NotificationGroupId gro
VLOG(notifications) << "Flush updates after get chat difference in " << group_id;
CHECK(group_id.is_valid());
if (!running_get_difference_ && pending_updates_.count(group_id.get()) == 1) {
remove_temporary_notifications(group_id);
remove_temporary_notifications(group_id, "after_get_chat_difference");
force_flush_pending_updates(group_id, "after_get_chat_difference");
}
}

View File

@ -73,7 +73,7 @@ class NotificationManager : public Actor {
void remove_notification(NotificationGroupId group_id, NotificationId notification_id, bool is_permanent,
bool force_update, Promise<Unit> &&promise);
void remove_temporary_notifications(NotificationGroupId group_id);
void remove_temporary_notifications(NotificationGroupId group_id, const char *source);
void remove_temporary_notification_by_message_id(NotificationGroupId group_id, MessageId message_id,
bool force_update);