Add simple group_key.last_notification_date sanity checks.
GitOrigin-RevId: d24887212101c976a2f25c203dbfff81caf12a74
This commit is contained in:
parent
b58b1a3612
commit
f0d3854462
@ -363,7 +363,11 @@ void NotificationManager::tear_down() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NotificationManager::NotificationGroups::iterator NotificationManager::add_group(NotificationGroupKey &&group_key,
|
NotificationManager::NotificationGroups::iterator NotificationManager::add_group(NotificationGroupKey &&group_key,
|
||||||
NotificationGroup &&group) {
|
NotificationGroup &&group,
|
||||||
|
const char *source) {
|
||||||
|
if (group.notifications.empty()) {
|
||||||
|
LOG_CHECK(group_key.last_notification_date == 0) << "Trying to add empty " << group_key << " from " << source;
|
||||||
|
}
|
||||||
bool is_inserted = group_keys_.emplace(group_key.group_id, group_key).second;
|
bool is_inserted = group_keys_.emplace(group_key.group_id, group_key).second;
|
||||||
CHECK(is_inserted);
|
CHECK(is_inserted);
|
||||||
return groups_.emplace(std::move(group_key), std::move(group)).first;
|
return groups_.emplace(std::move(group_key), std::move(group)).first;
|
||||||
@ -438,7 +442,7 @@ NotificationManager::NotificationGroups::iterator NotificationManager::get_group
|
|||||||
send_add_group_update(group_key, group);
|
send_add_group_update(group_key, group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return add_group(std::move(group_key), std::move(group));
|
return add_group(std::move(group_key), std::move(group), "get_group_force");
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::delete_group(NotificationGroups::iterator &&group_it) {
|
void NotificationManager::delete_group(NotificationGroups::iterator &&group_it) {
|
||||||
@ -709,8 +713,9 @@ void NotificationManager::add_notifications_to_group_begin(NotificationGroups::i
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_position_changed) {
|
if (is_position_changed) {
|
||||||
add_group(std::move(final_group_key), std::move(group));
|
add_group(std::move(final_group_key), std::move(group), "add_notifications_to_group_begin");
|
||||||
} else {
|
} else {
|
||||||
|
CHECK(group_it->first.last_notification_date == 0 || !group.notifications.empty());
|
||||||
group_it->second = std::move(group);
|
group_it->second = std::move(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -865,7 +870,7 @@ void NotificationManager::add_notification(NotificationGroupId group_id, Notific
|
|||||||
|
|
||||||
auto group_it = get_group_force(group_id);
|
auto group_it = get_group_force(group_id);
|
||||||
if (group_it == groups_.end()) {
|
if (group_it == groups_.end()) {
|
||||||
group_it = add_group(NotificationGroupKey(group_id, dialog_id, 0), NotificationGroup());
|
group_it = add_group(NotificationGroupKey(group_id, dialog_id, 0), NotificationGroup(), "add_notification");
|
||||||
}
|
}
|
||||||
if (group_it->second.notifications.empty() && group_it->second.pending_notifications.empty()) {
|
if (group_it->second.notifications.empty() && group_it->second.pending_notifications.empty()) {
|
||||||
group_it->second.type = group_type;
|
group_it->second.type = group_type;
|
||||||
@ -1552,7 +1557,7 @@ void NotificationManager::flush_pending_notifications(NotificationGroupId group_
|
|||||||
group.is_loaded_from_database = false;
|
group.is_loaded_from_database = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_group(std::move(final_group_key), std::move(group));
|
add_group(std::move(final_group_key), std::move(group), "flush_pending_notifications");
|
||||||
|
|
||||||
if (force_update) {
|
if (force_update) {
|
||||||
if (removed_group_id.is_valid()) {
|
if (removed_group_id.is_valid()) {
|
||||||
@ -1733,10 +1738,11 @@ void NotificationManager::on_notifications_removed(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_position_changed) {
|
if (is_position_changed) {
|
||||||
add_group(std::move(final_group_key), std::move(group));
|
add_group(std::move(final_group_key), std::move(group), "on_notifications_removed");
|
||||||
|
|
||||||
last_group_key = get_last_updated_group_key();
|
last_group_key = get_last_updated_group_key();
|
||||||
} else {
|
} else {
|
||||||
|
CHECK(group_it->first.last_notification_date == 0 || !group.notifications.empty());
|
||||||
group_it->second = std::move(group);
|
group_it->second = std::move(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,8 @@ class NotificationManager : public Actor {
|
|||||||
void add_update_notification(NotificationGroupId notification_group_id, DialogId dialog_id,
|
void add_update_notification(NotificationGroupId notification_group_id, DialogId dialog_id,
|
||||||
const Notification ¬ification);
|
const Notification ¬ification);
|
||||||
|
|
||||||
NotificationGroups::iterator add_group(NotificationGroupKey &&group_key, NotificationGroup &&group);
|
NotificationGroups::iterator add_group(NotificationGroupKey &&group_key, NotificationGroup &&group,
|
||||||
|
const char *source);
|
||||||
|
|
||||||
NotificationGroups::iterator get_group(NotificationGroupId group_id);
|
NotificationGroups::iterator get_group(NotificationGroupId group_id);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user