Add add_group/delete_group methods.
GitOrigin-RevId: 71539381c1b3600bc18b8c79c6cdb63ffff1cb0f
This commit is contained in:
parent
7466a29da7
commit
7ce70d8056
@ -17785,11 +17785,10 @@ int32 MessagesManager::get_dialog_pending_notification_count(Dialog *d) {
|
||||
CHECK(d != nullptr);
|
||||
if (is_dialog_muted(d)) {
|
||||
// TODO pinned message?
|
||||
// TODO hidden notifications?
|
||||
return d->unread_mention_count;
|
||||
}
|
||||
|
||||
return d->server_unread_count + d->local_unread_count; // TODO remove/add some messages with unread mentions
|
||||
return d->server_unread_count + d->local_unread_count; // TODO remove/add messages with unread mentions
|
||||
}
|
||||
|
||||
bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool force) {
|
||||
|
@ -154,6 +154,11 @@ void NotificationManager::tear_down() {
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
NotificationManager::NotificationGroups::iterator NotificationManager::add_group(NotificationGroupKey &&group_key,
|
||||
NotificationGroup &&group) {
|
||||
return groups_.emplace(std::move(group_key), std::move(group)).first;
|
||||
}
|
||||
|
||||
NotificationManager::NotificationGroups::iterator NotificationManager::get_group(NotificationGroupId group_id) {
|
||||
// TODO optimize
|
||||
for (auto it = groups_.begin(); it != groups_.end(); ++it) {
|
||||
@ -198,8 +203,11 @@ NotificationManager::NotificationGroups::iterator NotificationManager::get_group
|
||||
<< " and notifications " << group.notifications;
|
||||
|
||||
// TODO send update about the new group, if needed
|
||||
return add_group(std::move(group_key), std::move(group));
|
||||
}
|
||||
|
||||
return groups_.emplace(std::move(group_key), std::move(group)).first;
|
||||
void NotificationManager::delete_group(NotificationGroups::iterator &&group_it) {
|
||||
groups_.erase(group_it);
|
||||
}
|
||||
|
||||
int32 NotificationManager::load_message_notification_groups_from_database(int32 limit, bool send_update) {
|
||||
@ -331,8 +339,7 @@ void NotificationManager::add_notification(NotificationGroupId group_id, DialogI
|
||||
|
||||
auto group_it = get_group_force(group_id);
|
||||
if (group_it == groups_.end()) {
|
||||
NotificationGroupKey group_key(group_id, dialog_id, 0);
|
||||
group_it = std::move(groups_.emplace(group_key, NotificationGroup()).first);
|
||||
group_it = add_group(NotificationGroupKey(group_id, dialog_id, 0), NotificationGroup());
|
||||
}
|
||||
|
||||
PendingNotification notification;
|
||||
@ -857,7 +864,7 @@ void NotificationManager::flush_pending_notifications(NotificationGroupId group_
|
||||
auto group_key = group_it->first;
|
||||
auto group = std::move(group_it->second);
|
||||
|
||||
groups_.erase(group_it);
|
||||
delete_group(std::move(group_it));
|
||||
|
||||
auto final_group_key = group_key;
|
||||
for (auto &pending_notification : group.pending_notifications) {
|
||||
@ -919,7 +926,7 @@ void NotificationManager::flush_pending_notifications(NotificationGroupId group_
|
||||
group.notifications.begin() + (group.notifications.size() - keep_notification_group_size_));
|
||||
}
|
||||
|
||||
groups_.emplace(std::move(final_group_key), std::move(group));
|
||||
add_group(std::move(final_group_key), std::move(group));
|
||||
}
|
||||
|
||||
void NotificationManager::flush_all_pending_notifications() {
|
||||
@ -990,7 +997,7 @@ void NotificationManager::on_notifications_removed(
|
||||
NotificationGroup group = std::move(group_it->second);
|
||||
if (is_position_changed) {
|
||||
VLOG(notifications) << "Position of notification group is changed from " << group_key << " to " << final_group_key;
|
||||
groups_.erase(group_it);
|
||||
delete_group(std::move(group_it));
|
||||
}
|
||||
|
||||
auto last_group_key = get_last_updated_group_key();
|
||||
@ -1023,7 +1030,7 @@ void NotificationManager::on_notifications_removed(
|
||||
}
|
||||
|
||||
if (is_position_changed) {
|
||||
groups_.emplace(std::move(final_group_key), std::move(group));
|
||||
add_group(std::move(final_group_key), std::move(group));
|
||||
|
||||
last_group_key = get_last_updated_group_key();
|
||||
} else {
|
||||
|
@ -130,10 +130,14 @@ class NotificationManager : public Actor {
|
||||
void add_update_notification(NotificationGroupId notification_group_id, DialogId dialog_id,
|
||||
const Notification ¬ification);
|
||||
|
||||
NotificationGroups::iterator add_group(NotificationGroupKey &&group_key, NotificationGroup &&group);
|
||||
|
||||
NotificationGroups::iterator get_group(NotificationGroupId group_id);
|
||||
|
||||
NotificationGroups::iterator get_group_force(NotificationGroupId group_id, bool send_update = true);
|
||||
|
||||
void delete_group(NotificationGroups::iterator &&group_it);
|
||||
|
||||
int32 load_message_notification_groups_from_database(int32 limit, bool send_update);
|
||||
|
||||
NotificationGroupKey get_last_updated_group_key() const;
|
||||
|
Reference in New Issue
Block a user