Make non-const MessageReaction functions private.

This commit is contained in:
levlam 2022-09-13 15:35:18 +03:00
parent 38fbd00e99
commit 5213561096
3 changed files with 21 additions and 19 deletions

View File

@ -559,8 +559,8 @@ unique_ptr<MessageReactions> MessageReactions::get_message_reactions(
if (is_chosen) {
chosen_reaction_order.emplace_back(reaction_count->chosen_order_, reaction_str);
}
result->reactions_.emplace_back(std::move(reaction_str), reaction_count->count_, is_chosen,
std::move(recent_chooser_dialog_ids), std::move(recent_chooser_min_channels));
result->reactions_.push_back({std::move(reaction_str), reaction_count->count_, is_chosen,
std::move(recent_chooser_dialog_ids), std::move(recent_chooser_min_channels)});
}
if (chosen_reaction_order.size() > 1) {
std::sort(chosen_reaction_order.begin(), chosen_reaction_order.end());
@ -624,7 +624,7 @@ bool MessageReactions::add_reaction(const string &reaction, bool is_big, DialogI
if (have_recent_choosers) {
recent_chooser_dialog_ids.push_back(chooser_dialog_id);
}
reactions_.emplace_back(reaction, 1, true, std::move(recent_chooser_dialog_ids), Auto());
reactions_.push_back({reaction, 1, true, std::move(recent_chooser_dialog_ids), Auto()});
new_chosen_reaction_order.emplace_back(reaction);
} else if (!added_reaction->is_chosen()) {
added_reaction->set_is_chosen(true, chooser_dialog_id, have_recent_choosers);

View File

@ -36,11 +36,7 @@ class MessageReaction {
friend StringBuilder &operator<<(StringBuilder &string_builder, const MessageReaction &message_reaction);
public:
static constexpr size_t MAX_RECENT_CHOOSERS = 3;
static constexpr int32 MAX_CHOOSE_COUNT = 2147483640;
MessageReaction() = default;
friend struct MessageReactions;
MessageReaction(string reaction, int32 choose_count, bool is_chosen, vector<DialogId> &&recent_chooser_dialog_ids,
vector<std::pair<ChannelId, MinChannel>> &&recent_chooser_min_channels)
@ -55,16 +51,28 @@ class MessageReaction {
return choose_count_ <= 0;
}
const string &get_reaction() const {
return reaction_;
}
bool is_chosen() const {
return is_chosen_;
}
void set_is_chosen(bool is_chosen, DialogId chooser_dialog_id, bool have_recent_choosers);
void add_recent_chooser_dialog_id(DialogId dialog_id);
bool remove_recent_chooser_dialog_id(DialogId dialog_id);
void update_recent_chooser_dialog_ids(const MessageReaction &old_reaction);
public:
static constexpr size_t MAX_RECENT_CHOOSERS = 3;
static constexpr int32 MAX_CHOOSE_COUNT = 2147483640;
MessageReaction() = default;
const string &get_reaction() const {
return reaction_;
}
int32 get_choose_count() const {
return choose_count_;
}
@ -77,12 +85,6 @@ class MessageReaction {
return recent_chooser_min_channels_;
}
void add_recent_chooser_dialog_id(DialogId dialog_id);
bool remove_recent_chooser_dialog_id(DialogId dialog_id);
void update_recent_chooser_dialog_ids(const MessageReaction &old_reaction);
td_api::object_ptr<td_api::messageReaction> get_message_reaction_object(Td *td) const;
template <class StorerT>

View File

@ -6736,7 +6736,7 @@ void MessagesManager::on_get_message_reaction_list(FullMessageId full_message_id
};
// it's impossible to use received reactions to update message reactions, because there is no way to find,
// which reaction is chosen by the current user, so just reload message reactions for consistency
// which reactions are chosen by the current user, so just reload message reactions for consistency
bool need_reload = false;
if (reaction.empty()) {
// received list and total_count for all reactions