Do not try to load history in empty chats.

GitOrigin-RevId: 6ab22148eff7843abe251f7138e79f1f69f05b17
This commit is contained in:
levlam 2019-01-14 01:32:30 +03:00
parent 90cde3dea0
commit b19dacf20b
2 changed files with 5 additions and 4 deletions

View File

@ -815,8 +815,8 @@ class MessagesDbImpl : public MessagesDbSyncInterface {
stmt.bind_int64(2, from_message_id).ensure();
stmt.bind_int32(3, limit).ensure();
LOG(INFO) << "Load " << limit << " messages in " << DialogId(dialog_id) << " from " << MessageId(from_message_id)
<< " from database";
LOG(INFO) << "Begin to load " << limit << " messages in " << DialogId(dialog_id) << " from "
<< MessageId(from_message_id) << " from database";
std::vector<BufferSlice> result;
stmt.step().ensure();
while (stmt.has_row()) {

View File

@ -13128,8 +13128,9 @@ tl_object_ptr<td_api::messages> MessagesManager::get_dialog_history(DialogId dia
CHECK(offset == 0);
preload_newer_messages(d, MessageId(messages[0]->id_));
preload_older_messages(d, MessageId(messages.back()->id_));
} else if (messages.size() < static_cast<size_t>(limit) && left_tries != 0) {
// there can be more messages on the server, need to load them
} else if (messages.size() < static_cast<size_t>(limit) && left_tries != 0 &&
!(d->is_empty && d->have_full_history && left_tries < 3)) {
// there can be more messages in the database or on the server, need to load them
if (from_the_end) {
from_message_id = MessageId();
}