From 8aa8774dc795e89dd3c5ed1952c33e39356995db Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 31 May 2020 02:59:50 +0300 Subject: [PATCH] Move get_chat_list_object to DialogListId. GitOrigin-RevId: ba28ac3e722f3308ca3a8c20419b6d9a8642d6cc --- td/telegram/DialogListId.h | 18 ++++++++++++++++++ td/telegram/MessagesManager.cpp | 25 ++++--------------------- td/telegram/MessagesManager.h | 2 -- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/td/telegram/DialogListId.h b/td/telegram/DialogListId.h index 51d755a20..c1cf5d151 100644 --- a/td/telegram/DialogListId.h +++ b/td/telegram/DialogListId.h @@ -61,6 +61,24 @@ class DialogListId { } } + td_api::object_ptr get_chat_list_object() const { + if (is_folder()) { + auto folder_id = get_folder_id(); + if (folder_id == FolderId::archive()) { + return td_api::make_object(); + } + if (folder_id == FolderId::main()) { + return td_api::make_object(); + } + return td_api::make_object(); + } + if (is_filter()) { + return td_api::make_object(get_filter_id().get()); + } + UNREACHABLE(); + return nullptr; + } + int64 get() const { return id; } diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 8b8fa4db1..e806792d9 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -17350,23 +17350,6 @@ td_api::object_ptr MessagesManager::get_chat_type_object(Dialo } } -td_api::object_ptr MessagesManager::get_chat_list_object(DialogListId dialog_list_id) { - if (dialog_list_id.is_folder()) { - if (dialog_list_id == DialogListId(FolderId::archive())) { - return td_api::make_object(); - } - if (dialog_list_id == DialogListId(FolderId::main())) { - return td_api::make_object(); - } - return td_api::make_object(); - } - if (dialog_list_id.is_filter()) { - return td_api::make_object(dialog_list_id.get_filter_id().get()); - } - UNREACHABLE(); - return nullptr; -} - td_api::object_ptr MessagesManager::get_chat_action_bar_object(const Dialog *d) const { CHECK(d != nullptr); if (d->dialog_id.get_type() == DialogType::SecretChat) { @@ -25014,7 +24997,7 @@ void MessagesManager::send_update_chat_position(DialogListId dialog_list_id, con LOG(INFO) << "Send updateChatPosition for " << d->dialog_id << " in " << dialog_list_id << " from " << source; auto position = get_chat_position_object(dialog_list_id, d); if (position == nullptr) { - position = td_api::make_object(get_chat_list_object(dialog_list_id), 0, false, nullptr); + position = td_api::make_object(dialog_list_id.get_chat_list_object(), 0, false, nullptr); } send_closure(G()->td(), &Td::send_update, make_tl_object(d->dialog_id.get(), std::move(position))); @@ -30477,7 +30460,7 @@ td_api::object_ptr MessagesManager::get_chat_position_obje } auto chat_source = order.is_sponsored ? sponsored_dialog_source_.get_chat_source_object() : nullptr; - return td_api::make_object(get_chat_list_object(dialog_list_id), order.public_order, + return td_api::make_object(dialog_list_id.get_chat_list_object(), order.public_order, order.is_pinned, std::move(chat_source)); } @@ -33232,7 +33215,7 @@ td_api::object_ptr MessagesManager::get_update int32 unread_unmuted_count = list.unread_message_total_count_ - list.unread_message_muted_count_; CHECK(unread_count >= 0); CHECK(unread_unmuted_count >= 0); - return td_api::make_object(get_chat_list_object(list.dialog_list_id), unread_count, + return td_api::make_object(list.dialog_list_id.get_chat_list_object(), unread_count, unread_unmuted_count); } @@ -33249,7 +33232,7 @@ td_api::object_ptr MessagesManager::get_update_un CHECK(unread_marked_count >= 0); CHECK(unread_unmuted_marked_count >= 0); return td_api::make_object( - get_chat_list_object(list.dialog_list_id), get_dialog_total_count(list), unread_count, unread_unmuted_count, + list.dialog_list_id.get_chat_list_object(), get_dialog_total_count(list), unread_count, unread_unmuted_count, unread_marked_count, unread_unmuted_marked_count); } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 9afa7ce05..fe9f8d7c8 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -2210,8 +2210,6 @@ class MessagesManager : public Actor { td_api::object_ptr get_chat_type_object(DialogId dialog_id) const; - static td_api::object_ptr get_chat_list_object(DialogListId dialog_list_id); - td_api::object_ptr get_chat_action_bar_object(const Dialog *d) const; td_api::object_ptr get_chat_object(const Dialog *d, int64 real_order = DEFAULT_ORDER) const;