Trying to fix last_new_message_id.
GitOrigin-RevId: 13b336c88be9de4340feb4930741e22f2789de60
This commit is contained in:
parent
341c50f0e3
commit
68eea6e5bd
@ -6485,13 +6485,16 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|||||||
on_get_message(std::move(message), false, is_channel_message, false, have_next, "get history");
|
on_get_message(std::move(message), false, is_channel_message, false, have_next, "get history");
|
||||||
auto message_id = full_message_id.get_message_id();
|
auto message_id = full_message_id.get_message_id();
|
||||||
if (message_id.is_valid()) {
|
if (message_id.is_valid()) {
|
||||||
|
if (!last_added_message_id.is_valid()) {
|
||||||
|
last_added_message_id = message_id;
|
||||||
|
}
|
||||||
|
|
||||||
if (!have_next) {
|
if (!have_next) {
|
||||||
if (d == nullptr) {
|
if (d == nullptr) {
|
||||||
d = get_dialog(dialog_id);
|
d = get_dialog(dialog_id);
|
||||||
CHECK(d != nullptr);
|
CHECK(d != nullptr);
|
||||||
}
|
}
|
||||||
have_next = true;
|
have_next = true;
|
||||||
last_added_message_id = message_id;
|
|
||||||
} else if (first_added_message_id.is_valid()) {
|
} else if (first_added_message_id.is_valid()) {
|
||||||
Message *next_message = get_message(d, first_added_message_id);
|
Message *next_message = get_message(d, first_added_message_id);
|
||||||
CHECK(next_message != nullptr);
|
CHECK(next_message != nullptr);
|
||||||
@ -13527,8 +13530,8 @@ void MessagesManager::get_history_from_the_end(DialogId dialog_id, bool from_dat
|
|||||||
G()->td_db()->get_messages_db_async()->get_messages(
|
G()->td_db()->get_messages_db_async()->get_messages(
|
||||||
db_query, PromiseCreator::lambda([dialog_id, only_local, limit, actor_id = actor_id(this),
|
db_query, PromiseCreator::lambda([dialog_id, only_local, limit, actor_id = actor_id(this),
|
||||||
promise = std::move(promise)](MessagesDbMessagesResult result) mutable {
|
promise = std::move(promise)](MessagesDbMessagesResult result) mutable {
|
||||||
send_closure(actor_id, &MessagesManager::on_get_history_from_database, dialog_id, MessageId::max(), 0,
|
send_closure(actor_id, &MessagesManager::on_get_history_from_database, dialog_id, MessageId::max(), 0, limit,
|
||||||
limit, true, only_local, std::move(result.messages), std::move(promise));
|
true, only_local, std::move(result.messages), std::move(promise));
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
if (only_local || dialog_id.get_type() == DialogType::SecretChat) {
|
if (only_local || dialog_id.get_type() == DialogType::SecretChat) {
|
||||||
@ -21306,7 +21309,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
|||||||
*need_update_dialog_pos = true;
|
*need_update_dialog_pos = true;
|
||||||
}
|
}
|
||||||
if (auto_attach && !message_id.is_yet_unsent() && message_id.get() >= d->last_new_message_id.get() &&
|
if (auto_attach && !message_id.is_yet_unsent() && message_id.get() >= d->last_new_message_id.get() &&
|
||||||
(d->last_new_message_id.is_valid() || message_id.get() >= d->last_message_id.get())) {
|
(d->last_new_message_id.is_valid() || (message_id.is_local() && message_id.get() >= d->last_message_id.get()))) {
|
||||||
CHECK(message_id.get() <= d->last_message_id.get());
|
CHECK(message_id.get() <= d->last_message_id.get());
|
||||||
if (message_id.get() > d->last_database_message_id.get()) {
|
if (message_id.get() > d->last_database_message_id.get()) {
|
||||||
set_dialog_last_database_message_id(d, message_id, "add_message_to_dialog");
|
set_dialog_last_database_message_id(d, message_id, "add_message_to_dialog");
|
||||||
@ -22613,6 +22616,12 @@ MessagesManager::Dialog *MessagesManager::add_new_dialog(unique_ptr<Dialog> &&d,
|
|||||||
set_dialog_first_database_message_id(dialog, message_id, "add_new_dialog");
|
set_dialog_first_database_message_id(dialog, message_id, "add_new_dialog");
|
||||||
}
|
}
|
||||||
set_dialog_last_database_message_id(dialog, message_id, "add_new_dialog");
|
set_dialog_last_database_message_id(dialog, message_id, "add_new_dialog");
|
||||||
|
if ((message_id.is_server() || dialog_id.get_type() == DialogType::SecretChat) &&
|
||||||
|
!dialog->last_new_message_id.is_valid()) {
|
||||||
|
// is it even possible?
|
||||||
|
LOG(ERROR) << "Bugfixing wrong last_new_message_id to " << message_id;
|
||||||
|
set_dialog_last_new_message_id(dialog, message_id, "add_new_dialog");
|
||||||
|
}
|
||||||
|
|
||||||
int32 dependent_dialog_count = 0;
|
int32 dependent_dialog_count = 0;
|
||||||
if (last_database_message->forward_info != nullptr) {
|
if (last_database_message->forward_info != nullptr) {
|
||||||
|
Reference in New Issue
Block a user