Use traverse_messages to find minimum message identifier.
This commit is contained in:
parent
0d1cdc3e60
commit
5ecc3a0968
@ -21056,14 +21056,18 @@ tl_object_ptr<td_api::messages> MessagesManager::get_dialog_history(DialogId dia
|
|||||||
bool have_a_gap = false;
|
bool have_a_gap = false;
|
||||||
if (*p == nullptr) {
|
if (*p == nullptr) {
|
||||||
// there is no gap if from_message_id is less than first message in the dialog
|
// there is no gap if from_message_id is less than first message in the dialog
|
||||||
if (left_tries == 0 && d->ordered_messages.messages_ != nullptr && offset < 0) {
|
if (left_tries == 0 && offset < 0 && !d->messages.empty()) {
|
||||||
const OrderedMessage *cur = d->ordered_messages.messages_.get();
|
MessageId min_message_id;
|
||||||
while (cur->left != nullptr) {
|
d->ordered_messages.traverse_messages(
|
||||||
cur = cur->left.get();
|
[&](MessageId message_id) {
|
||||||
}
|
min_message_id = message_id;
|
||||||
CHECK(cur->message_id > from_message_id);
|
return true;
|
||||||
from_message_id = cur->message_id;
|
},
|
||||||
|
[](MessageId) { return false; });
|
||||||
|
CHECK(min_message_id > from_message_id);
|
||||||
|
from_message_id = min_message_id;
|
||||||
p = d->ordered_messages.get_const_iterator(from_message_id);
|
p = d->ordered_messages.get_const_iterator(from_message_id);
|
||||||
|
CHECK(*p != nullptr);
|
||||||
} else {
|
} else {
|
||||||
have_a_gap = true;
|
have_a_gap = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user