From 71ec8cc6552820aa583814f0a465f5d5eadd524e Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 8 Jun 2020 01:22:59 +0300 Subject: [PATCH] Send updateChatFilters for empty list of chat filters after logging in. GitOrigin-RevId: 18176b0c9bd08a1552189bb35eb46a982a33732d --- td/telegram/MessagesManager.cpp | 16 ++++++++++++---- td/telegram/MessagesManager.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 1f01ab41a..71898b90e 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -14323,11 +14323,11 @@ void MessagesManager::on_get_dialog_filters(Resultunix_time(); if (server_dialog_filters_ != new_server_dialog_filters) { LOG(INFO) << "Change server chat filters from " << get_dialog_filter_ids(server_dialog_filters_) << " to " << get_dialog_filter_ids(new_server_dialog_filters); - bool is_changed = false; std::unordered_map old_server_dialog_filters; for (const auto &filter : server_dialog_filters_) { old_server_dialog_filters.emplace(filter->dialog_filter_id, filter.get()); @@ -14412,9 +14412,9 @@ void MessagesManager::on_get_dialog_filters(Result= MAX_DIALOG_FILTERS) { return promise.set_error(Status::Error(400, "Maximum number of chat folders exceeded")); } + if (!is_update_chat_filters_sent_) { + return promise.set_error(Status::Error(400, "Chat folders are not synchronized yet")); + } DialogFilterId dialog_filter_id; do { @@ -15565,6 +15568,7 @@ void MessagesManager::edit_dialog_filter(DialogFilterId dialog_filter_id, td_api if (old_dialog_filter == nullptr) { return promise.set_error(Status::Error(400, "Chat filter not found")); } + CHECK(is_update_chat_filters_sent_); auto r_dialog_filter = create_dialog_filter(dialog_filter_id, std::move(filter)); if (r_dialog_filter.is_error()) { @@ -16301,6 +16305,7 @@ Status MessagesManager::toggle_dialog_is_pinned(DialogListId dialog_list_id, Dia } if (dialog_list_id.is_filter()) { + CHECK(is_update_chat_filters_sent_); auto dialog_filter_id = dialog_list_id.get_filter_id(); auto old_dialog_filter = get_dialog_filter(dialog_filter_id); CHECK(old_dialog_filter != nullptr); @@ -16458,6 +16463,7 @@ Status MessagesManager::set_pinned_dialogs(DialogListId dialog_list_id, vectortd(), &Td::send_update, get_update_chat_filters_object()); } @@ -26983,6 +26990,7 @@ void MessagesManager::add_dialog_to_list(DialogId dialog_id, DialogListId dialog } if (dialog_list_id.is_filter()) { + CHECK(is_update_chat_filters_sent_); auto dialog_filter_id = dialog_list_id.get_filter_id(); auto old_dialog_filter = get_dialog_filter(dialog_filter_id); CHECK(old_dialog_filter != nullptr); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 0e0b93550..f7b3a7629 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -2930,6 +2930,7 @@ class MessagesManager : public Actor { bool are_dialog_filters_being_reloaded_ = false; bool need_dialog_filters_reload_ = false; bool disable_get_dialog_filter_ = false; + bool is_update_chat_filters_sent_ = false; int32 dialog_filters_updated_date_ = 0; vector> server_dialog_filters_; vector> dialog_filters_;