From fa99ec2875cae4ac7e703c56692ceb09f8a7ae62 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 10 May 2018 21:26:46 +0300 Subject: [PATCH] Add promoted dialog to dialog list. GitOrigin-RevId: db6936972df14739081b288cb270dc1560e46c61 --- td/telegram/MessagesManager.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index b04ccdd21..4cceb58b2 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -24270,12 +24270,15 @@ void MessagesManager::update_dialog_pos(Dialog *d, bool remove_from_dialog_list, } } } - if (new_order == DEFAULT_ORDER && !d->is_empty) { + if (d->dialog_id != promoted_dialog_id_ && new_order == DEFAULT_ORDER && !d->is_empty) { // if there is no known messages in the dialog, just leave it where it is LOG(INFO) << "There is no known messages in the dialog"; return; } } + if (new_order == DEFAULT_ORDER && d->dialog_id == promoted_dialog_id_) { + new_order = static_cast(2147483647) << 32; + } if (set_dialog_order(d, new_order, need_send_update_chat_order)) { on_dialog_updated(d->dialog_id, "update_dialog_pos"); @@ -25879,14 +25882,20 @@ void MessagesManager::set_promoted_dialog_id(DialogId dialog_id) { return; } - promoted_dialog_id_ = dialog_id; + if (promoted_dialog_id_.is_valid()) { + Dialog *d = get_dialog(promoted_dialog_id_); + CHECK(d != nullptr); + promoted_dialog_id_ = DialogId(); + update_dialog_pos(d, false, "delete_promoted_dialog_id"); + } + if (dialog_id.is_valid()) { force_create_dialog(dialog_id, "set_promoted_dialog_id"); - /* + Dialog *d = get_dialog(dialog_id); CHECK(d != nullptr); + promoted_dialog_id_ = dialog_id; update_dialog_pos(d, false, "set_promoted_dialog_id"); - */ } if (G()->parameters().use_message_db) {