Add NotificationGroupInfo::set_max_removed_notification_id.
This commit is contained in:
parent
d22fbcaba6
commit
f933f5a25f
@ -11970,14 +11970,9 @@ void MessagesManager::delete_all_dialog_messages(Dialog *d, bool remove_from_dia
|
|||||||
delete_all_dialog_messages_from_database(d, MessageId::max(), "delete_all_dialog_messages 3");
|
delete_all_dialog_messages_from_database(d, MessageId::max(), "delete_all_dialog_messages 3");
|
||||||
|
|
||||||
if (d->notification_info != nullptr) {
|
if (d->notification_info != nullptr) {
|
||||||
d->notification_info->message_notification_group_.max_removed_notification_id_ =
|
// they aren't needed anymore
|
||||||
NotificationId(); // it is not needed anymore
|
d->notification_info->message_notification_group_.drop_max_removed_notification_id();
|
||||||
d->notification_info->message_notification_group_.max_removed_message_id_ =
|
d->notification_info->mention_notification_group_.drop_max_removed_notification_id();
|
||||||
MessageId(); // it is not needed anymore
|
|
||||||
d->notification_info->mention_notification_group_.max_removed_notification_id_ =
|
|
||||||
NotificationId(); // it is not needed anymore
|
|
||||||
d->notification_info->mention_notification_group_.max_removed_message_id_ =
|
|
||||||
MessageId(); // it is not needed anymore
|
|
||||||
d->notification_info->notification_id_to_message_id_.clear();
|
d->notification_info->notification_id_to_message_id_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29757,25 +29752,14 @@ void MessagesManager::remove_message_notifications(DialogId dialog_id, Notificat
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto &group_info = get_notification_group_info(d, from_mentions);
|
auto &group_info = get_notification_group_info(d, from_mentions);
|
||||||
if (max_notification_id.get() <= group_info.max_removed_notification_id_.get()) {
|
if (group_info.set_max_removed_notification_id(max_notification_id, max_message_id, "remove_message_notifications")) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (max_message_id > group_info.max_removed_message_id_) {
|
|
||||||
VLOG(notifications) << "Set max_removed_message_id in " << group_info.group_id_ << '/' << dialog_id << " to "
|
|
||||||
<< max_message_id;
|
|
||||||
group_info.max_removed_message_id_ = max_message_id.get_prev_server_message_id();
|
|
||||||
}
|
|
||||||
|
|
||||||
VLOG(notifications) << "Set max_removed_notification_id in " << group_info.group_id_ << '/' << dialog_id << " to "
|
|
||||||
<< max_notification_id;
|
|
||||||
group_info.max_removed_notification_id_ = max_notification_id;
|
|
||||||
on_dialog_updated(dialog_id, "remove_message_notifications");
|
on_dialog_updated(dialog_id, "remove_message_notifications");
|
||||||
|
|
||||||
if (group_info.last_notification_id_.is_valid() &&
|
if (group_info.last_notification_id_.is_valid() &&
|
||||||
max_notification_id.get() >= group_info.last_notification_id_.get()) {
|
max_notification_id.get() >= group_info.last_notification_id_.get()) {
|
||||||
set_dialog_last_notification_checked(dialog_id, group_info, 0, NotificationId(), "remove_message_notifications");
|
set_dialog_last_notification_checked(dialog_id, group_info, 0, NotificationId(), "remove_message_notifications");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32 MessagesManager::get_dialog_pending_notification_count(const Dialog *d, bool from_mentions) const {
|
int32 MessagesManager::get_dialog_pending_notification_count(const Dialog *d, bool from_mentions) const {
|
||||||
CHECK(!td_->auth_manager_->is_bot());
|
CHECK(!td_->auth_manager_->is_bot());
|
||||||
@ -30123,13 +30107,11 @@ void MessagesManager::remove_all_dialog_notifications(Dialog *d, bool from_menti
|
|||||||
NotificationGroupInfo &group_info = get_notification_group_info(d, from_mentions);
|
NotificationGroupInfo &group_info = get_notification_group_info(d, from_mentions);
|
||||||
if (group_info.group_id_.is_valid() && group_info.last_notification_id_.is_valid() &&
|
if (group_info.group_id_.is_valid() && group_info.last_notification_id_.is_valid() &&
|
||||||
group_info.max_removed_notification_id_ != group_info.last_notification_id_) {
|
group_info.max_removed_notification_id_ != group_info.last_notification_id_) {
|
||||||
VLOG(notifications) << "Set max_removed_notification_id in " << group_info.group_id_ << '/' << d->dialog_id
|
if (group_info.set_max_removed_notification_id(group_info.last_notification_id_,
|
||||||
<< " to " << group_info.last_notification_id_ << " from " << source;
|
d->notification_info->max_notification_message_id_, source)) {
|
||||||
group_info.max_removed_notification_id_ = group_info.last_notification_id_;
|
on_dialog_updated(d->dialog_id, source);
|
||||||
if (d->notification_info->max_notification_message_id_ > group_info.max_removed_message_id_) {
|
|
||||||
group_info.max_removed_message_id_ =
|
|
||||||
d->notification_info->max_notification_message_id_.get_prev_server_message_id();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->notification_info->pending_new_message_notifications_.empty()) {
|
if (!d->notification_info->pending_new_message_notifications_.empty()) {
|
||||||
for (auto &it : d->notification_info->pending_new_message_notifications_) {
|
for (auto &it : d->notification_info->pending_new_message_notifications_) {
|
||||||
it.first = DialogId();
|
it.first = DialogId();
|
||||||
|
@ -25,6 +25,36 @@ bool NotificationGroupInfo::set_last_notification(int32 last_notification_date,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NotificationGroupInfo::set_max_removed_notification_id(NotificationId max_removed_notification_id,
|
||||||
|
MessageId max_removed_message_id, const char *source) {
|
||||||
|
if (max_removed_notification_id.get() <= max_removed_notification_id_.get()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (max_removed_message_id > max_removed_message_id_) {
|
||||||
|
VLOG(notifications) << "Set max_removed_message_id in " << group_id_ << " to " << max_removed_message_id << " from "
|
||||||
|
<< source;
|
||||||
|
max_removed_message_id_ = max_removed_message_id.get_prev_server_message_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
VLOG(notifications) << "Set max_removed_notification_id in " << group_id_ << " to " << max_removed_notification_id
|
||||||
|
<< " from " << source;
|
||||||
|
max_removed_notification_id_ = max_removed_notification_id;
|
||||||
|
is_changed_ = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotificationGroupInfo::drop_max_removed_notification_id() {
|
||||||
|
if (!max_removed_notification_id_.is_valid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VLOG(notifications) << "Drop max_removed_notification_id in " << group_id_;
|
||||||
|
max_removed_message_id_ = MessageId();
|
||||||
|
max_removed_notification_id_ = NotificationId();
|
||||||
|
is_changed_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
void NotificationGroupInfo::try_reuse() {
|
void NotificationGroupInfo::try_reuse() {
|
||||||
CHECK(group_id_.is_valid());
|
CHECK(group_id_.is_valid());
|
||||||
CHECK(last_notification_date_ == 0);
|
CHECK(last_notification_date_ == 0);
|
||||||
|
@ -36,6 +36,11 @@ class NotificationGroupInfo {
|
|||||||
|
|
||||||
bool set_last_notification(int32 last_notification_date, NotificationId last_notification_id, const char *source);
|
bool set_last_notification(int32 last_notification_date, NotificationId last_notification_id, const char *source);
|
||||||
|
|
||||||
|
bool set_max_removed_notification_id(NotificationId max_removed_notification_id, MessageId max_removed_message_id,
|
||||||
|
const char *source);
|
||||||
|
|
||||||
|
void drop_max_removed_notification_id();
|
||||||
|
|
||||||
void try_reuse();
|
void try_reuse();
|
||||||
|
|
||||||
void add_group_key_if_changed(vector<NotificationGroupKey> &group_keys, DialogId dialog_id);
|
void add_group_key_if_changed(vector<NotificationGroupKey> &group_keys, DialogId dialog_id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user