Add need_synchronize_dialog_filters.
GitOrigin-RevId: e108099952a97aaa7b2963e15fff0123e1e3cbda
This commit is contained in:
parent
2edf3282fc
commit
260ac6c90e
@ -11134,8 +11134,12 @@ void MessagesManager::init() {
|
||||
G()->td_db()->get_binlog_pmc()->erase("nsfac");
|
||||
|
||||
if (!td_->auth_manager_->is_bot()) {
|
||||
auto cache_time = get_dialog_filters_cache_time();
|
||||
schedule_dialog_filters_reload(cache_time - max(0, G()->unix_time() - dialog_filters_updated_date_));
|
||||
if (need_synchronize_dialog_filters()) {
|
||||
reload_dialog_filters();
|
||||
} else {
|
||||
auto cache_time = get_dialog_filters_cache_time();
|
||||
schedule_dialog_filters_reload(cache_time - max(0, G()->unix_time() - dialog_filters_updated_date_));
|
||||
}
|
||||
}
|
||||
|
||||
auto auth_notification_ids_string = G()->td_db()->get_binlog_pmc()->get("auth_notification_ids");
|
||||
@ -14394,6 +14398,23 @@ void MessagesManager::on_get_dialog_filters(Result<vector<tl_object_ptr<telegram
|
||||
}
|
||||
}
|
||||
|
||||
bool MessagesManager::need_synchronize_dialog_filters() const {
|
||||
vector<InputDialogId> empty_input_dialog_ids;
|
||||
size_t server_dialog_filter_count = 0;
|
||||
for (auto &dialog_filter : dialog_filters_) {
|
||||
if (dialog_filter->is_empty(true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
server_dialog_filter_count++;
|
||||
auto server_dialog_filter = get_server_dialog_filter(dialog_filter->dialog_filter_id);
|
||||
if (server_dialog_filter == nullptr || !DialogFilter::are_equivalent(*server_dialog_filter, *dialog_filter)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return server_dialog_filter_count != server_dialog_filters_.size();
|
||||
}
|
||||
|
||||
vector<DialogId> MessagesManager::search_public_dialogs(const string &query, Promise<Unit> &&promise) {
|
||||
LOG(INFO) << "Search public chats with query = \"" << query << '"';
|
||||
|
||||
|
@ -2238,6 +2238,8 @@ class MessagesManager : public Actor {
|
||||
|
||||
void on_get_dialog_filters(Result<vector<tl_object_ptr<telegram_api::dialogFilter>>> r_filters, bool dummy);
|
||||
|
||||
bool need_synchronize_dialog_filters() const;
|
||||
|
||||
void update_dialogs_hints(const Dialog *d);
|
||||
void update_dialogs_hints_rating(const Dialog *d);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user