Return default tag reactions first for tags.

This commit is contained in:
levlam 2024-01-23 16:49:50 +03:00
parent 9a09125d62
commit 1c53d32aba
3 changed files with 26 additions and 12 deletions

View File

@ -22618,6 +22618,11 @@ void MessagesManager::on_get_scheduled_messages_from_database(DialogId dialog_id
set_promises(promises); set_promises(promises);
} }
bool MessagesManager::can_add_message_tag(DialogId dialog_id, const MessageReactions *reactions) const {
return dialog_id == td_->dialog_manager_->get_my_dialog_id() &&
(reactions == nullptr || reactions->reactions_.empty() || reactions->are_tags_);
}
Result<td_api::object_ptr<td_api::availableReactions>> MessagesManager::get_message_available_reactions( Result<td_api::object_ptr<td_api::availableReactions>> MessagesManager::get_message_available_reactions(
MessageFullId message_full_id, int32 row_size) { MessageFullId message_full_id, int32 row_size) {
auto dialog_id = message_full_id.get_dialog_id(); auto dialog_id = message_full_id.get_dialog_id();
@ -22631,13 +22636,9 @@ Result<td_api::object_ptr<td_api::availableReactions>> MessagesManager::get_mess
return Status::Error(400, "Message not found"); return Status::Error(400, "Message not found");
} }
bool is_tag = can_add_message_tag(dialog_id, m->reactions.get());
return td_->reaction_manager_->get_sorted_available_reactions(get_message_available_reactions(d, m, false), return td_->reaction_manager_->get_sorted_available_reactions(get_message_available_reactions(d, m, false),
get_message_active_reactions(d, m), row_size); get_message_active_reactions(d, m), row_size, is_tag);
}
bool MessagesManager::can_add_message_tag(DialogId dialog_id, const MessageReactions *reactions) const {
return dialog_id == td_->dialog_manager_->get_my_dialog_id() &&
(reactions == nullptr || reactions->reactions_.empty() || reactions->are_tags_);
} }
ChatReactions MessagesManager::get_message_available_reactions(const Dialog *d, const Message *m, ChatReactions MessagesManager::get_message_available_reactions(const Dialog *d, const Message *m,

View File

@ -283,8 +283,12 @@ void ReactionManager::get_emoji_reaction(const string &emoji,
} }
td_api::object_ptr<td_api::availableReactions> ReactionManager::get_sorted_available_reactions( td_api::object_ptr<td_api::availableReactions> ReactionManager::get_sorted_available_reactions(
ChatReactions available_reactions, ChatReactions active_reactions, int32 row_size) { ChatReactions available_reactions, ChatReactions active_reactions, int32 row_size, bool is_tag) {
load_reaction_list(ReactionListType::Recent); if (is_tag) {
load_reaction_list(ReactionListType::DefaultTag);
} else {
load_reaction_list(ReactionListType::Recent);
}
load_reaction_list(ReactionListType::Top); load_reaction_list(ReactionListType::Top);
if (row_size < 5 || row_size > 25) { if (row_size < 5 || row_size > 25) {
@ -293,8 +297,17 @@ td_api::object_ptr<td_api::availableReactions> ReactionManager::get_sorted_avail
bool is_premium = td_->option_manager_->get_option_boolean("is_premium"); bool is_premium = td_->option_manager_->get_option_boolean("is_premium");
bool show_premium = is_premium; bool show_premium = is_premium;
const auto &recent_reactions = get_reaction_list(ReactionListType::Recent).reaction_types_; vector<ReactionType> recent_reactions;
auto top_reactions = get_reaction_list(ReactionListType::Top).reaction_types_; vector<ReactionType> top_reactions;
if (is_tag) {
top_reactions = get_reaction_list(ReactionListType::DefaultTag).reaction_types_;
if (is_premium) {
append(top_reactions, get_reaction_list(ReactionListType::Top).reaction_types_);
}
} else {
recent_reactions = get_reaction_list(ReactionListType::Recent).reaction_types_;
top_reactions = get_reaction_list(ReactionListType::Top).reaction_types_;
}
LOG(INFO) << "Have available reactions " << available_reactions << " to be sorted by top reactions " << top_reactions LOG(INFO) << "Have available reactions " << available_reactions << " to be sorted by top reactions " << top_reactions
<< " and recent reactions " << recent_reactions; << " and recent reactions " << recent_reactions;
if (active_reactions.allow_all_custom_ && active_reactions.allow_all_regular_) { if (active_reactions.allow_all_custom_ && active_reactions.allow_all_regular_) {
@ -386,7 +399,7 @@ td_api::object_ptr<td_api::availableReactions> ReactionManager::get_available_re
ChatReactions available_reactions; ChatReactions available_reactions;
available_reactions.reaction_types_ = active_reaction_types_; available_reactions.reaction_types_ = active_reaction_types_;
available_reactions.allow_all_custom_ = true; available_reactions.allow_all_custom_ = true;
return get_sorted_available_reactions(std::move(available_reactions), ChatReactions(true, true), row_size); return get_sorted_available_reactions(std::move(available_reactions), ChatReactions(true, true), row_size, false);
} }
void ReactionManager::add_recent_reaction(const ReactionType &reaction_type) { void ReactionManager::add_recent_reaction(const ReactionType &reaction_type) {

View File

@ -43,7 +43,7 @@ class ReactionManager final : public Actor {
td_api::object_ptr<td_api::availableReactions> get_sorted_available_reactions(ChatReactions available_reactions, td_api::object_ptr<td_api::availableReactions> get_sorted_available_reactions(ChatReactions available_reactions,
ChatReactions active_reactions, ChatReactions active_reactions,
int32 row_size); int32 row_size, bool is_tag);
td_api::object_ptr<td_api::availableReactions> get_available_reactions(int32 row_size); td_api::object_ptr<td_api::availableReactions> get_available_reactions(int32 row_size);