Improve getting groups in common.

GitOrigin-RevId: 211d8706823b9aa509af00855083a1981a0a963a
This commit is contained in:
levlam 2019-06-05 03:14:54 +03:00
parent 6d2842d0b4
commit 0181982749
3 changed files with 10 additions and 4 deletions

View File

@ -7123,6 +7123,10 @@ void ContactsManager::on_update_user_common_chat_count(UserId user_id, int32 com
void ContactsManager::on_update_user_full_common_chat_count(UserFull *user_full, UserId user_id,
int32 common_chat_count) {
CHECK(user_full != nullptr);
if (common_chat_count < 0) {
LOG(ERROR) << "Receive " << common_chat_count << " as common group count with " << user_id;
common_chat_count = 0;
}
if (user_full->is_inited && user_full->common_chat_count != common_chat_count) {
user_full->common_chat_count = common_chat_count;
user_full->is_common_chat_count_changed = true;

View File

@ -11876,6 +11876,7 @@ void MessagesManager::on_get_common_dialogs(UserId user_id, int32 offset_chat_id
if (!result.empty() && result.back() == DialogId()) {
return;
}
bool is_last = chats.empty() && offset_chat_id == 0;
for (auto &chat : chats) {
DialogId dialog_id;
switch (chat->get_id()) {
@ -11940,7 +11941,7 @@ void MessagesManager::on_get_common_dialogs(UserId user_id, int32 offset_chat_id
result.push_back(dialog_id);
}
}
if (result.size() >= static_cast<size_t>(total_count)) {
if (result.size() >= static_cast<size_t>(total_count) || is_last) {
result.push_back(DialogId());
}
}
@ -23510,8 +23511,8 @@ bool MessagesManager::update_message(Dialog *d, unique_ptr<Message> &old_message
old_type != MessageContentType::ExpiredPhoto && old_type != MessageContentType::ExpiredVideo) {
LOG(ERROR) << message_id << " in " << dialog_id << " has changed contains_mention from "
<< old_message->contains_mention << " to " << new_message->contains_mention
<< ", is_outgoing = " << old_message->is_outgoing << ", message content type is "
<< old_type << '/' << new_message->content->get_type();
<< ", is_outgoing = " << old_message->is_outgoing << ", message content type is " << old_type << '/'
<< new_message->content->get_type();
}
// contains_mention flag shouldn't be changed, because the message will not be added to unread mention list
// and we are unable to show/hide message notification

View File

@ -2896,7 +2896,8 @@ void StickersManager::on_get_archived_sticker_sets(
// if 0 sticker sets are received then set offset_sticker_set_id was found and there is no stickers after it
// or it wasn't found and there is no archived sets at all
bool is_last =
sticker_sets.empty() && (offset_sticker_set_id == 0 || offset_sticker_set_id == sticker_set_ids.back());
sticker_sets.empty() &&
(offset_sticker_set_id == 0 || (!sticker_set_ids.empty() && offset_sticker_set_id == sticker_set_ids.back()));
total_archived_sticker_set_count_[is_masks] = total_count;
for (auto &sticker_set_covered : sticker_sets) {