Don't reload message reactions for messages with being read reactions.

This commit is contained in:
levlam 2023-06-23 14:39:07 +03:00
parent 50fdce9ae1
commit fca432eb43
2 changed files with 15 additions and 2 deletions

View File

@ -21,6 +21,7 @@
#include "td/telegram/UpdatesManager.h"
#include "td/actor/actor.h"
#include "td/actor/SleepActor.h"
#include "td/utils/algorithm.h"
#include "td/utils/as.h"
@ -957,6 +958,12 @@ bool is_active_reaction(const string &reaction, const FlatHashMap<string, size_t
void reload_message_reactions(Td *td, DialogId dialog_id, vector<MessageId> &&message_ids) {
if (!td->messages_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
dialog_id.get_type() == DialogType::SecretChat || message_ids.empty()) {
create_actor<SleepActor>(
"RetryReloadMessageReactionsActor", 0.2,
PromiseCreator::lambda([actor_id = G()->messages_manager(), dialog_id](Result<Unit> result) mutable {
send_closure(actor_id, &MessagesManager::try_reload_message_reactions, dialog_id, true);
}))
.release();
return;
}

View File

@ -7176,7 +7176,10 @@ bool MessagesManager::update_message_interaction_info(Dialog *d, Message *m, int
need_update_reactions || need_update_unread_reactions || need_update_chosen_reaction_order) {
LOG(DEBUG) << "Update interaction info of " << full_message_id << " from " << m->view_count << '/'
<< m->forward_count << '/' << m->reply_info << '/' << m->reactions << " to " << view_count << '/'
<< forward_count << '/' << reply_info << '/' << reactions;
<< forward_count << '/' << reply_info << '/' << reactions
<< ", need_update_reactions = " << need_update_reactions
<< ", need_update_unread_reactions = " << need_update_unread_reactions
<< ", need_update_chosen_reaction_order = " << need_update_chosen_reaction_order;
bool need_update = false;
if (view_count > m->view_count) {
m->view_count = view_count;
@ -8612,7 +8615,10 @@ void MessagesManager::try_reload_message_reactions(DialogId dialog_id, bool is_f
vector<MessageId> message_ids;
for (auto message_id_it = it->second.message_ids.begin();
message_id_it != it->second.message_ids.end() && message_ids.size() < MAX_MESSAGE_IDS; ++message_id_it) {
message_ids.push_back(*message_id_it);
auto message_id = *message_id_it;
if (pending_read_reactions_.count({dialog_id, message_id}) == 0) {
message_ids.push_back(message_id);
}
}
for (auto message_id : message_ids) {
it->second.message_ids.erase(message_id);