Add need_dialog_in_filter.

GitOrigin-RevId: 1a9d7bd58e7d660ac148643ed0cd06df7d35b2a3
This commit is contained in:
levlam 2020-05-26 16:21:26 +03:00
parent d053d46b26
commit e3dc7198c5
2 changed files with 80 additions and 72 deletions

View File

@ -30490,17 +30490,11 @@ bool MessagesManager::is_dialog_in_list(const Dialog *d, const DialogList &list)
return td::contains(d->dialog_list_ids, list.dialog_list_id); return td::contains(d->dialog_list_ids, list.dialog_list_id);
} }
bool MessagesManager::need_dialog_in_list(const Dialog *d, const DialogList &list) const { bool MessagesManager::need_dialog_in_filter(const Dialog *d, const DialogFilter *filter) const {
if (d->order == DEFAULT_ORDER) { CHECK(d != nullptr);
return false;
}
if (list.dialog_list_id.is_folder()) {
return d->folder_id == list.dialog_list_id.get_folder_id();
}
if (list.dialog_list_id.is_filter()) {
auto dialog_filter_id = list.dialog_list_id.get_filter_id();
auto *filter = get_dialog_filter(dialog_filter_id);
CHECK(filter != nullptr); CHECK(filter != nullptr);
CHECK(d->order != DEFAULT_ORDER);
auto matches = [](const vector<InputDialogId> input_dialog_ids, DialogId dialog_id) { auto matches = [](const vector<InputDialogId> input_dialog_ids, DialogId dialog_id) {
for (auto &input_dialog_id : input_dialog_ids) { for (auto &input_dialog_id : input_dialog_ids) {
if (input_dialog_id.get_dialog_id() == dialog_id) { if (input_dialog_id.get_dialog_id() == dialog_id) {
@ -30572,6 +30566,18 @@ bool MessagesManager::need_dialog_in_list(const Dialog *d, const DialogList &lis
return false; return false;
} }
} }
bool MessagesManager::need_dialog_in_list(const Dialog *d, const DialogList &list) const {
if (d->order == DEFAULT_ORDER) {
return false;
}
if (list.dialog_list_id.is_folder()) {
return d->folder_id == list.dialog_list_id.get_folder_id();
}
if (list.dialog_list_id.is_filter()) {
auto dialog_filter_id = list.dialog_list_id.get_filter_id();
return need_dialog_in_filter(d, get_dialog_filter(dialog_filter_id));
}
UNREACHABLE(); UNREACHABLE();
return false; return false;
} }

View File

@ -2274,6 +2274,8 @@ class MessagesManager : public Actor {
bool is_dialog_in_list(const Dialog *d, const DialogList &list) const; bool is_dialog_in_list(const Dialog *d, const DialogList &list) const;
bool need_dialog_in_filter(const Dialog *d, const DialogFilter *filter) const;
bool need_dialog_in_list(const Dialog *d, const DialogList &list) const; bool need_dialog_in_list(const Dialog *d, const DialogList &list) const;
DialogOrderInList get_dialog_order_in_list(const DialogList *list, const Dialog *d, bool actual = false) const; DialogOrderInList get_dialog_order_in_list(const DialogList *list, const Dialog *d, bool actual = false) const;