Fix pinned_message_notification_message_id after notification removal.

GitOrigin-RevId: 88cd26d1888a83c5d3448f9f2deeb92ed96140ec
This commit is contained in:
levlam 2019-01-07 23:30:34 +03:00
parent 8e402b8a48
commit eeb2faede0

View File

@ -10568,6 +10568,9 @@ void MessagesManager::remove_message_notification_id(Dialog *d, Message *m, bool
<< ", is_permanent = " << is_permanent; << ", is_permanent = " << is_permanent;
delete_notification_id_to_message_id_correspondence(d, notification_id, m->message_id); delete_notification_id_to_message_id_correspondence(d, notification_id, m->message_id);
m->notification_id = NotificationId(); m->notification_id = NotificationId();
if (d->pinned_message_notification_message_id == m->message_id && is_permanent) {
set_dialog_pinned_message_notification(d, MessageId()); // must be called after notification_id is removed
}
if (group_info.last_notification_id == notification_id) { if (group_info.last_notification_id == notification_id) {
// last notification is deleted, need to find new last notification // last notification is deleted, need to find new last notification
fix_dialog_last_notification_id(d, from_mentions, m->message_id); fix_dialog_last_notification_id(d, from_mentions, m->message_id);
@ -17822,7 +17825,7 @@ void MessagesManager::try_add_pinned_message_notification(Dialog *d, vector<Noti
} }
auto m = get_message_force(d, message_id); auto m = get_message_force(d, message_id);
if (m->notification_id.get() > d->mention_notification_group.max_removed_notification_id.get()) { if (m != nullptr && m->notification_id.get() > d->mention_notification_group.max_removed_notification_id.get()) {
if (m->notification_id.get() < max_notification_id.get()) { if (m->notification_id.get() < max_notification_id.get()) {
VLOG(notifications) << "Add " << m->notification_id << " about pinned " << message_id << " in " << d->dialog_id; VLOG(notifications) << "Add " << m->notification_id << " about pinned " << message_id << " in " << d->dialog_id;
auto pos = res.size(); auto pos = res.size();