Reload full chat info after pinned message is dropped.

GitOrigin-RevId: 6cbf3d217b5da21f050715ed290cb122d6a4ef2c
This commit is contained in:
levlam 2020-10-28 14:25:27 +03:00
parent 0ec0f20f62
commit 974feddb4a
3 changed files with 29 additions and 4 deletions

View File

@ -12353,7 +12353,7 @@ void ContactsManager::reload_dialog_info(DialogId dialog_id, Promise<Unit> &&pro
case DialogType::Channel:
return reload_channel(dialog_id.get_channel_id(), std::move(promise));
default:
promise.set_error(Status::Error("Invalid dialog ID to reload"));
return promise.set_error(Status::Error("Invalid dialog ID to reload"));
}
}

View File

@ -9657,7 +9657,7 @@ bool MessagesManager::update_message_is_pinned(Dialog *d, Message *m, bool is_pi
}
} else {
if (m->message_id == d->last_pinned_message_id) {
if (d->message_count_by_index[message_search_filter_index(MessageSearchFilter::Pinned)] == 1) {
if (d->message_count_by_index[message_search_filter_index(MessageSearchFilter::Pinned)] == 0) {
set_dialog_last_pinned_message_id(d, MessageId());
} else {
drop_dialog_last_pinned_message_id(d);
@ -16348,6 +16348,28 @@ void MessagesManager::get_dialog_info_full(DialogId dialog_id, Promise<Unit> &&p
}
}
void MessagesManager::reload_dialog_info_full(DialogId dialog_id) {
switch (dialog_id.get_type()) {
case DialogType::User:
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_user_full, dialog_id.get_user_id());
return;
case DialogType::Chat:
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_chat_full, dialog_id.get_chat_id(),
Promise<Unit>());
return;
case DialogType::Channel:
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_channel_full, dialog_id.get_channel_id(),
Promise<Unit>(), "reload_dialog_info_full");
return;
case DialogType::SecretChat:
return;
case DialogType::None:
default:
UNREACHABLE();
return;
}
}
MessageId MessagesManager::get_dialog_pinned_message(DialogId dialog_id, Promise<Unit> &&promise) {
Dialog *d = get_dialog_force(dialog_id);
if (d == nullptr) {
@ -28497,6 +28519,8 @@ void MessagesManager::drop_dialog_last_pinned_message_id(Dialog *d) {
on_dialog_updated(d->dialog_id, "drop_dialog_last_pinned_message_id");
LOG(INFO) << "Drop " << d->dialog_id << " pinned message";
reload_dialog_info_full(d->dialog_id);
}
void MessagesManager::repair_dialog_scheduled_messages(Dialog *d) {
@ -32343,8 +32367,7 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr
// old_message->is_from_scheduled = new_message->is_from_scheduled;
}
if (!is_scheduled &&
update_message_is_pinned(d, old_message, new_message->is_pinned, "update_message")) {
if (!is_scheduled && update_message_is_pinned(d, old_message, new_message->is_pinned, "update_message")) {
need_send_update = true;
}

View File

@ -2427,6 +2427,8 @@ class MessagesManager : public Actor {
void send_search_public_dialogs_query(const string &query, Promise<Unit> &&promise);
void reload_dialog_info_full(DialogId dialog_id);
vector<DialogId> get_pinned_dialog_ids(DialogListId dialog_list_id) const;
void reload_pinned_dialogs(DialogListId dialog_list_id, Promise<Unit> &&promise);