Simplify limit initialization in get_history_from_the_end_impl.

This commit is contained in:
levlam 2023-07-27 18:19:10 +03:00
parent b914b28bf0
commit 5c8b12b105

View File

@ -23464,12 +23464,9 @@ void MessagesManager::get_history_from_the_end_impl(const Dialog *d, bool from_d
if (!d->first_database_message_id.is_valid() && !d->have_full_history) { if (!d->first_database_message_id.is_valid() && !d->have_full_history) {
from_database = false; from_database = false;
} }
int32 limit = MAX_GET_HISTORY; // load only 10 messages when repairing the last message and can't save the result to the database
int32 limit = !promise && (from_database || !G()->use_message_database()) ? 10 : MAX_GET_HISTORY;
if (from_database && G()->use_message_database()) { if (from_database && G()->use_message_database()) {
if (!promise) {
// repair last database message ID
limit = 10;
}
LOG(INFO) << "Get history from the end of " << dialog_id << " from database from " << source; LOG(INFO) << "Get history from the end of " << dialog_id << " from database from " << source;
MessageDbMessagesQuery db_query; MessageDbMessagesQuery db_query;
db_query.dialog_id = dialog_id; db_query.dialog_id = dialog_id;
@ -23490,10 +23487,6 @@ void MessagesManager::get_history_from_the_end_impl(const Dialog *d, bool from_d
promise.set_value(Unit()); promise.set_value(Unit());
return; return;
} }
if (!promise && !G()->use_message_database()) {
// repair last message ID
limit = 10;
}
LOG(INFO) << "Get history from the end of " << dialog_id << " from server from " << source; LOG(INFO) << "Get history from the end of " << dialog_id << " from server from " << source;
td_->create_handler<GetHistoryQuery>(std::move(promise)) td_->create_handler<GetHistoryQuery>(std::move(promise))