More cases for temporary notification removal.

GitOrigin-RevId: 0f617980b80f94cc415fbda922c7462ca4675045
This commit is contained in:
levlam 2019-04-10 23:22:03 +03:00
parent 59f36b3b3d
commit 009c78ce5b
3 changed files with 24 additions and 4 deletions

View File

@ -19250,6 +19250,17 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f
CHECK(d != nullptr);
CHECK(m != nullptr);
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);
}
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);
}
}
CHECK(!m->notification_id.is_valid());
if (is_message_notification_disabled(d, m)) {
return false;
@ -22992,6 +23003,11 @@ void MessagesManager::delete_message_from_database(Dialog *d, MessageId message_
m->notification_id, true, false, Promise<Unit>());
}
}
} else if (message_id.get() > d->last_new_message_id.get()) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
d->message_notification_group.group_id, message_id, false);
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
d->mention_notification_group.group_id, message_id, false);
}
auto need_delete_message_files = m != nullptr && (d->dialog_id.get_type() == DialogType::User ||
@ -24851,7 +24867,7 @@ void MessagesManager::on_get_channel_difference(
}
void MessagesManager::after_get_channel_difference(DialogId dialog_id, bool success) {
LOG(INFO) << "After " << (success ? "un" : "") << "successful get channel difference in " << dialog_id;
LOG(INFO) << "After " << (success ? "" : "un") << "successful get channel difference in " << dialog_id;
LOG_CHECK(!running_get_channel_difference(dialog_id)) << '"' << active_get_channel_differencies_[dialog_id] << '"';
auto logevent_it = get_channel_difference_to_logevent_id_.find(dialog_id);

View File

@ -2048,11 +2048,15 @@ void NotificationManager::remove_temporary_notifications(NotificationGroupId gro
return;
}
auto group_it = get_group_force(group_id);
auto group_it = get_group(group_id);
if (group_it == groups_.end()) {
return;
}
if (get_temporary_notification_total_count(group_it->second) == 0) {
return;
}
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;

View File

@ -73,6 +73,8 @@ 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_notification_by_message_id(NotificationGroupId group_id, MessageId message_id,
bool force_update);
@ -226,8 +228,6 @@ class NotificationManager : public Actor {
static int32 get_temporary_notification_total_count(const NotificationGroup &group);
void remove_temporary_notifications(NotificationGroupId group_id);
int32 load_message_notification_groups_from_database(int32 limit, bool send_update);
void load_message_notifications_from_database(const NotificationGroupKey &group_key, NotificationGroup &group,