From 4f7791121f6caaa9bac2d51e80ced30181cd8852 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 20 Oct 2020 20:44:46 +0300 Subject: [PATCH] Update pinned message count when message.is_pinned changed. GitOrigin-RevId: 924aa4f4fdd009d2eb8b6603e10d19566d346444 --- td/telegram/MessagesManager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index f371f7f47..abe3fcd1b 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -9615,7 +9615,12 @@ bool MessagesManager::update_message_is_pinned(Dialog *d, Message *m, bool is_pi LOG(INFO) << "Update message is_pinned of " << m->message_id << " in " << d->dialog_id << " to " << is_pinned << " from " << source; + auto old_index_mask = get_message_index_mask(d->dialog_id, m); m->is_pinned = is_pinned; + auto new_index_mask = get_message_index_mask(d->dialog_id, m); + update_message_count_by_index(d, -1, old_index_mask & ~new_index_mask); + update_message_count_by_index(d, +1, new_index_mask & ~old_index_mask); + send_closure(G()->td(), &Td::send_update, make_tl_object(d->dialog_id.get(), m->message_id.get(), is_pinned)); if (is_pinned) {