Move get_dialog_search_text to DialogManager.
This commit is contained in:
parent
899587e4fa
commit
3d80f1ae6f
@ -5361,23 +5361,6 @@ string ContactsManager::get_secret_chat_about(SecretChatId secret_chat_id) {
|
|||||||
return get_user_about(c->user_id);
|
return get_user_about(c->user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
string ContactsManager::get_dialog_search_text(DialogId dialog_id) const {
|
|
||||||
switch (dialog_id.get_type()) {
|
|
||||||
case DialogType::User:
|
|
||||||
return get_user_search_text(dialog_id.get_user_id());
|
|
||||||
case DialogType::Chat:
|
|
||||||
return get_chat_title(dialog_id.get_chat_id());
|
|
||||||
case DialogType::Channel:
|
|
||||||
return get_channel_search_text(dialog_id.get_channel_id());
|
|
||||||
case DialogType::SecretChat:
|
|
||||||
return get_user_search_text(get_secret_chat_user_id(dialog_id.get_secret_chat_id()));
|
|
||||||
case DialogType::None:
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
|
||||||
return string();
|
|
||||||
}
|
|
||||||
|
|
||||||
string ContactsManager::get_user_search_text(UserId user_id) const {
|
string ContactsManager::get_user_search_text(UserId user_id) const {
|
||||||
auto u = get_user(user_id);
|
auto u = get_user(user_id);
|
||||||
if (u == nullptr) {
|
if (u == nullptr) {
|
||||||
@ -5396,11 +5379,6 @@ string ContactsManager::get_channel_search_text(ChannelId channel_id) const {
|
|||||||
if (c == nullptr) {
|
if (c == nullptr) {
|
||||||
return get_channel_title(channel_id);
|
return get_channel_title(channel_id);
|
||||||
}
|
}
|
||||||
return get_channel_search_text(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
string ContactsManager::get_channel_search_text(const Channel *c) {
|
|
||||||
CHECK(c != nullptr);
|
|
||||||
return PSTRING() << c->title << ' ' << implode(c->usernames.get_active_usernames());
|
return PSTRING() << c->title << ' ' << implode(c->usernames.get_active_usernames());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17063,7 +17041,7 @@ std::pair<int32, vector<DialogId>> ContactsManager::search_among_dialogs(const v
|
|||||||
if (query.empty()) {
|
if (query.empty()) {
|
||||||
hints.add(dialog_id.get(), Slice(" "));
|
hints.add(dialog_id.get(), Slice(" "));
|
||||||
} else {
|
} else {
|
||||||
hints.add(dialog_id.get(), get_dialog_search_text(dialog_id));
|
hints.add(dialog_id.get(), td_->dialog_manager_->get_dialog_search_text(dialog_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hints.set_rating(dialog_id.get(), rating);
|
hints.set_rating(dialog_id.get(), rating);
|
||||||
|
@ -172,7 +172,9 @@ class ContactsManager final : public Actor {
|
|||||||
|
|
||||||
bool get_user_read_dates_private(UserId user_id);
|
bool get_user_read_dates_private(UserId user_id);
|
||||||
|
|
||||||
string get_dialog_search_text(DialogId dialog_id) const;
|
string get_user_search_text(UserId user_id) const;
|
||||||
|
|
||||||
|
string get_channel_search_text(ChannelId channel_id) const;
|
||||||
|
|
||||||
void for_each_secret_chat_with_user(UserId user_id, const std::function<void(SecretChatId)> &f);
|
void for_each_secret_chat_with_user(UserId user_id, const std::function<void(SecretChatId)> &f);
|
||||||
|
|
||||||
@ -1400,7 +1402,6 @@ class ContactsManager final : public Actor {
|
|||||||
|
|
||||||
SecretChat *add_secret_chat(SecretChatId secret_chat_id);
|
SecretChat *add_secret_chat(SecretChatId secret_chat_id);
|
||||||
|
|
||||||
string get_user_search_text(UserId user_id) const;
|
|
||||||
static string get_user_search_text(const User *u);
|
static string get_user_search_text(const User *u);
|
||||||
|
|
||||||
static DialogParticipantStatus get_chat_status(const Chat *c);
|
static DialogParticipantStatus get_chat_status(const Chat *c);
|
||||||
@ -1415,9 +1416,6 @@ class ContactsManager final : public Actor {
|
|||||||
static bool get_channel_join_to_send(const Channel *c);
|
static bool get_channel_join_to_send(const Channel *c);
|
||||||
static bool get_channel_join_request(const Channel *c);
|
static bool get_channel_join_request(const Channel *c);
|
||||||
|
|
||||||
string get_channel_search_text(ChannelId channel_id) const;
|
|
||||||
static string get_channel_search_text(const Channel *c);
|
|
||||||
|
|
||||||
void set_my_id(UserId my_id);
|
void set_my_id(UserId my_id);
|
||||||
|
|
||||||
void on_set_emoji_status(EmojiStatus emoji_status, Promise<Unit> &&promise);
|
void on_set_emoji_status(EmojiStatus emoji_status, Promise<Unit> &&promise);
|
||||||
|
@ -1107,6 +1107,24 @@ string DialogManager::get_dialog_about(DialogId dialog_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string DialogManager::get_dialog_search_text(DialogId dialog_id) const {
|
||||||
|
switch (dialog_id.get_type()) {
|
||||||
|
case DialogType::User:
|
||||||
|
return td_->contacts_manager_->get_user_search_text(dialog_id.get_user_id());
|
||||||
|
case DialogType::Chat:
|
||||||
|
return td_->contacts_manager_->get_chat_title(dialog_id.get_chat_id());
|
||||||
|
case DialogType::Channel:
|
||||||
|
return td_->contacts_manager_->get_channel_search_text(dialog_id.get_channel_id());
|
||||||
|
case DialogType::SecretChat:
|
||||||
|
return td_->contacts_manager_->get_user_search_text(
|
||||||
|
td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id()));
|
||||||
|
case DialogType::None:
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
|
||||||
bool DialogManager::get_dialog_has_protected_content(DialogId dialog_id) const {
|
bool DialogManager::get_dialog_has_protected_content(DialogId dialog_id) const {
|
||||||
switch (dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
|
@ -135,6 +135,8 @@ class DialogManager final : public Actor {
|
|||||||
|
|
||||||
string get_dialog_about(DialogId dialog_id);
|
string get_dialog_about(DialogId dialog_id);
|
||||||
|
|
||||||
|
string get_dialog_search_text(DialogId dialog_id) const;
|
||||||
|
|
||||||
bool get_dialog_has_protected_content(DialogId dialog_id) const;
|
bool get_dialog_has_protected_content(DialogId dialog_id) const;
|
||||||
|
|
||||||
bool is_dialog_action_unneeded(DialogId dialog_id) const;
|
bool is_dialog_action_unneeded(DialogId dialog_id) const;
|
||||||
|
@ -15992,7 +15992,7 @@ std::pair<int32, vector<DialogId>> MessagesManager::search_recently_found_dialog
|
|||||||
Hints hints;
|
Hints hints;
|
||||||
int rating = 1;
|
int rating = 1;
|
||||||
for (auto dialog_id : result.second) {
|
for (auto dialog_id : result.second) {
|
||||||
hints.add(dialog_id.get(), td_->contacts_manager_->get_dialog_search_text(dialog_id));
|
hints.add(dialog_id.get(), td_->dialog_manager_->get_dialog_search_text(dialog_id));
|
||||||
hints.set_rating(dialog_id.get(), ++rating);
|
hints.set_rating(dialog_id.get(), ++rating);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34705,7 +34705,7 @@ bool MessagesManager::add_pending_dialog_data(Dialog *d, unique_ptr<Message> &&l
|
|||||||
|
|
||||||
void MessagesManager::update_dialogs_hints(const Dialog *d) {
|
void MessagesManager::update_dialogs_hints(const Dialog *d) {
|
||||||
if (!td_->auth_manager_->is_bot() && d->order != DEFAULT_ORDER) {
|
if (!td_->auth_manager_->is_bot() && d->order != DEFAULT_ORDER) {
|
||||||
dialogs_hints_.add(-d->dialog_id.get(), td_->contacts_manager_->get_dialog_search_text(d->dialog_id));
|
dialogs_hints_.add(-d->dialog_id.get(), td_->dialog_manager_->get_dialog_search_text(d->dialog_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user