Move get_dialog_filter_folder_ids to DialogFilter.
This commit is contained in:
parent
d8a7114a2b
commit
bfc0361b02
@ -490,6 +490,13 @@ void DialogFilter::sort_input_dialog_ids(const Td *td, const char *source) {
|
||||
});
|
||||
}
|
||||
|
||||
vector<FolderId> DialogFilter::get_folder_ids() const {
|
||||
if (exclude_archived && pinned_dialog_ids.empty() && included_dialog_ids.empty()) {
|
||||
return {FolderId::main()};
|
||||
}
|
||||
return {FolderId::main(), FolderId::archive()};
|
||||
}
|
||||
|
||||
bool DialogFilter::are_similar(const DialogFilter &lhs, const DialogFilter &rhs) {
|
||||
if (lhs.title == rhs.title) {
|
||||
return true;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/DialogFilterId.h"
|
||||
#include "td/telegram/FolderId.h"
|
||||
#include "td/telegram/InputDialogId.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
@ -78,6 +79,8 @@ class DialogFilter {
|
||||
|
||||
void sort_input_dialog_ids(const Td *td, const char *source);
|
||||
|
||||
vector<FolderId> get_folder_ids() const;
|
||||
|
||||
static bool are_similar(const DialogFilter &lhs, const DialogFilter &rhs);
|
||||
|
||||
static bool are_equivalent(const DialogFilter &lhs, const DialogFilter &rhs);
|
||||
|
@ -20032,9 +20032,9 @@ void MessagesManager::edit_dialog_filter(unique_ptr<DialogFilter> new_dialog_fil
|
||||
|
||||
disable_get_dialog_filter_ = true; // to ensure crash if get_dialog_filter is called
|
||||
|
||||
auto folder_ids = get_dialog_filter_folder_ids(old_dialog_filter.get());
|
||||
auto folder_ids = old_dialog_filter->get_folder_ids();
|
||||
CHECK(!folder_ids.empty());
|
||||
for (auto folder_id : get_dialog_filter_folder_ids(new_dialog_filter.get())) {
|
||||
for (auto folder_id : new_dialog_filter->get_folder_ids()) {
|
||||
if (!td::contains(folder_ids, folder_id)) {
|
||||
folder_ids.push_back(folder_id);
|
||||
}
|
||||
@ -20070,7 +20070,7 @@ void MessagesManager::edit_dialog_filter(unique_ptr<DialogFilter> new_dialog_fil
|
||||
new_list.are_pinned_dialogs_inited_ = true;
|
||||
|
||||
do_update_list_last_pinned_dialog_date(new_list);
|
||||
do_update_list_last_dialog_date(new_list, get_dialog_filter_folder_ids(new_dialog_filter.get()));
|
||||
do_update_list_last_dialog_date(new_list, new_dialog_filter->get_folder_ids());
|
||||
|
||||
new_list.server_dialog_total_count_ = 0;
|
||||
new_list.secret_chat_total_count_ = 0;
|
||||
@ -39070,14 +39070,6 @@ vector<DialogFilterId> MessagesManager::get_dialog_filter_ids(const vector<uniqu
|
||||
return result;
|
||||
}
|
||||
|
||||
vector<FolderId> MessagesManager::get_dialog_filter_folder_ids(const DialogFilter *filter) {
|
||||
CHECK(filter != nullptr);
|
||||
if (filter->exclude_archived && filter->pinned_dialog_ids.empty() && filter->included_dialog_ids.empty()) {
|
||||
return {FolderId::main()};
|
||||
}
|
||||
return {FolderId::main(), FolderId::archive()};
|
||||
}
|
||||
|
||||
vector<FolderId> MessagesManager::get_dialog_list_folder_ids(const DialogList &list) const {
|
||||
CHECK(!td_->auth_manager_->is_bot());
|
||||
if (list.dialog_list_id.is_folder()) {
|
||||
@ -39085,7 +39077,7 @@ vector<FolderId> MessagesManager::get_dialog_list_folder_ids(const DialogList &l
|
||||
}
|
||||
if (list.dialog_list_id.is_filter()) {
|
||||
auto dialog_filter_id = list.dialog_list_id.get_filter_id();
|
||||
return get_dialog_filter_folder_ids(get_dialog_filter(dialog_filter_id));
|
||||
return get_dialog_filter(dialog_filter_id)->get_folder_ids();
|
||||
}
|
||||
UNREACHABLE();
|
||||
return {};
|
||||
|
@ -2897,8 +2897,6 @@ class MessagesManager final : public Actor {
|
||||
static vector<DialogFilterId> get_dialog_filter_ids(const vector<unique_ptr<DialogFilter>> &dialog_filters,
|
||||
int32 main_dialog_list_position);
|
||||
|
||||
static vector<FolderId> get_dialog_filter_folder_ids(const DialogFilter *filter);
|
||||
|
||||
vector<FolderId> get_dialog_list_folder_ids(const DialogList &list) const;
|
||||
|
||||
bool has_dialogs_from_folder(const DialogList &list, const DialogFolder &folder) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user