From ae1db34f447a273aa6daee77b075cdff978927b5 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 26 May 2020 02:46:22 +0300 Subject: [PATCH] Minor improvements. GitOrigin-RevId: 788f6c7cf686489fd54ba20b12a9f670e7b4d04f --- td/telegram/MessagesManager.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index f33ac9a27..f28931927 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -14273,15 +14273,17 @@ void MessagesManager::on_get_dialog_filters(Result(*new_server_filter), "on_get_dialog_filters 1"); } else { - // the filter was edited both locally and remotely - // TODO merge local and remote changes - edit_dialog_filter(make_unique(*new_server_filter), "on_get_dialog_filters 2"); + if (*old_filter == *new_server_filter) { // fast path + // the filter was edited from this client and doesn't contain chosen secret chats, nothing to do + } else if (*old_filter == *old_server_filter) { // fast path + // the filter was edited only from another client and doesn't contain chosen secret chats + edit_dialog_filter(make_unique(*new_server_filter), "on_get_dialog_filters 1"); + } else { + // TODO apply changes between old_server_filter and new_server_filter to old_filter + // remember that old_filter can contain secret chats, which must be kept + edit_dialog_filter(make_unique(*new_server_filter), "on_get_dialog_filters 2"); + } } } old_server_dialog_filters.erase(it); @@ -14289,12 +14291,11 @@ void MessagesManager::on_get_dialog_filters(Result(*new_server_filter), "on_get_dialog_filters"); - } else if (*old_filter == *new_server_filter) { - // the filter was added from that client, nothing to do } else { - // the filter was added from two different client simultaneously, - // or it was added and edited from that client + // the filter was added from this client + // after that it could be added from another client, or edited from this client, or edited from another client // prefer local value, so do nothing + // effectively, ignore edits from other clients, if didn't receive UpdateDialogFilterQuery response } } } @@ -15845,10 +15846,11 @@ Status MessagesManager::toggle_dialog_is_pinned(DialogListId dialog_list_id, Dia return Status::OK(); } - if (!dialog_list_id.is_folder()) { + if (dialog_list_id.is_filter()) { return Status::Error(500, "TODO support"); } + CHECK(dialog_list_id.is_folder()); auto folder_id = dialog_list_id.get_folder_id(); if (is_pinned) { if (d->folder_id != folder_id) { @@ -15962,10 +15964,11 @@ Status MessagesManager::set_pinned_dialogs(DialogListId dialog_list_id, vectordialog_id, group_info, 0, NotificationId(), "remove_message_dialog_notifications 2"); } else { - LOG(FATAL) << "TODO support deleting up to " << max_message_id << " if ever will be needed"; + LOG(FATAL) << "TODO support notification deletion up to " << max_message_id << " if will be ever needed"; } send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification_group, group_info.group_id,