Return default icon name if there is no chosen name in chatFilterInfo.
This commit is contained in:
parent
5f965a1ea4
commit
680bad4a72
@ -890,7 +890,7 @@ chatTypeSecret secret_chat_id:int32 user_id:int53 = ChatType;
|
||||
|
||||
//@description Represents a filter of user chats
|
||||
//@title The title of the filter; 1-12 characters without line feeds
|
||||
//@icon_name The icon name for short filter representation. If non-empty, must be one of "All", "Unread", "Unmuted", "Bots", "Channels", "Groups", "Private", "Custom", "Setup", "Cat", "Crown", "Favorite", "Flower", "Game", "Home", "Love", "Mask", "Party", "Sport", "Study", "Trade", "Travel", "Work".
|
||||
//@icon_name The chosen icon name for short filter representation. If non-empty, must be one of "All", "Unread", "Unmuted", "Bots", "Channels", "Groups", "Private", "Custom", "Setup", "Cat", "Crown", "Favorite", "Flower", "Game", "Home", "Love", "Mask", "Party", "Sport", "Study", "Trade", "Travel", "Work".
|
||||
//-If empty, use getChatFilterDefaultIconName to get default icon name for the filter
|
||||
//@pinned_chat_ids The chat identifiers of pinned chats in the filtered chat list
|
||||
//@included_chat_ids The chat identifiers of always included chats in the filtered chat list
|
||||
@ -908,7 +908,7 @@ chatFilter title:string icon_name:string pinned_chat_ids:vector<int53> included_
|
||||
//@description Contains basic information about a chat filter
|
||||
//@id Unique chat filter identifier
|
||||
//@title The title of the filter; 1-12 characters without line feeds
|
||||
//@icon_name The icon name for short filter representation. One of "All", "Unread", "Unmuted", "Bots", "Channels", "Groups", "Private", "Custom", "Setup", "Cat", "Crown", "Favorite", "Flower", "Game", "Home", "Love", "Mask", "Party", "Sport", "Study", "Trade", "Travel", "Work"
|
||||
//@icon_name The chosen or default icon name for short filter representation. One of "All", "Unread", "Unmuted", "Bots", "Channels", "Groups", "Private", "Custom", "Setup", "Cat", "Crown", "Favorite", "Flower", "Game", "Home", "Love", "Mask", "Party", "Sport", "Study", "Trade", "Travel", "Work"
|
||||
chatFilterInfo id:int32 title:string icon_name:string = ChatFilterInfo;
|
||||
|
||||
//@description Describes a recommended chat filter @filter The chat filter @param_description Chat filter description
|
||||
|
@ -131,6 +131,44 @@ string DialogFilter::get_icon_name() const {
|
||||
return string();
|
||||
}
|
||||
|
||||
string DialogFilter::get_chosen_or_default_icon_name() const {
|
||||
auto icon_name = get_icon_name();
|
||||
if (!icon_name.empty()) {
|
||||
return icon_name;
|
||||
}
|
||||
|
||||
if (!pinned_dialog_ids.empty() || !included_dialog_ids.empty() || !excluded_dialog_ids.empty()) {
|
||||
return "Custom";
|
||||
}
|
||||
|
||||
if (include_contacts || include_non_contacts) {
|
||||
if (!include_bots && !include_groups && !include_channels) {
|
||||
return "Private";
|
||||
}
|
||||
} else {
|
||||
if (!include_bots && !include_channels) {
|
||||
if (!include_groups) {
|
||||
// just in case
|
||||
return "Custom";
|
||||
}
|
||||
return "Groups";
|
||||
}
|
||||
if (!include_bots && !include_groups) {
|
||||
return "Channels";
|
||||
}
|
||||
if (!include_groups && !include_channels) {
|
||||
return "Bots";
|
||||
}
|
||||
}
|
||||
if (exclude_read && !exclude_muted) {
|
||||
return "Unread";
|
||||
}
|
||||
if (exclude_muted && !exclude_read) {
|
||||
return "Unmuted";
|
||||
}
|
||||
return "Custom";
|
||||
}
|
||||
|
||||
string DialogFilter::get_default_icon_name(const td_api::chatFilter *filter) {
|
||||
if (!filter->icon_name_.empty() && !get_emoji_by_icon_name(filter->icon_name_).empty()) {
|
||||
return filter->icon_name_;
|
||||
@ -206,7 +244,7 @@ telegram_api::object_ptr<telegram_api::dialogFilter> DialogFilter::get_input_dia
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::chatFilterInfo> DialogFilter::get_chat_filter_info_object() const {
|
||||
return td_api::make_object<td_api::chatFilterInfo>(dialog_filter_id.get(), title, get_icon_name());
|
||||
return td_api::make_object<td_api::chatFilterInfo>(dialog_filter_id.get(), title, get_chosen_or_default_icon_name());
|
||||
}
|
||||
|
||||
// merges changes from old_server_filter to new_server_filter in old_filter
|
||||
|
@ -79,6 +79,8 @@ class DialogFilter {
|
||||
static std::unordered_map<string, string> icon_name_to_emoji_;
|
||||
|
||||
static void init_icon_names();
|
||||
|
||||
string get_chosen_or_default_icon_name() const;
|
||||
};
|
||||
|
||||
inline bool operator==(const DialogFilter &lhs, const DialogFilter &rhs) {
|
||||
|
Loading…
Reference in New Issue
Block a user