MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / loadAround

Method loadAround

Telegram/SourceFiles/data/data_replies_list.cpp:528–582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

526}
527
528void RepliesList::loadAround(MsgId id) {
529 Expects(!_creating);
530
531 if (_loadingAround && *_loadingAround == id) {
532 return;
533 }
534 histories().cancelRequest(base::take(_beforeId));
535 histories().cancelRequest(base::take(_afterId));
536
537 const auto send = [=](Fn<void()> finish) {
538 return _history->session().api().request(MTPmessages_GetReplies(
539 _history->peer->input(),
540 MTP_int(_rootId),
541 MTP_int(id), // offset_id
542 MTP_int(0), // offset_date
543 MTP_int(id ? (-kMessagesPerPage / 2) : 0), // add_offset
544 MTP_int(kMessagesPerPage), // limit
545 MTP_int(0), // max_id
546 MTP_int(0), // min_id
547 MTP_long(0) // hash
548 )).done([=](const MTPmessages_Messages &result) {
549 _beforeId = 0;
550 _loadingAround = std::nullopt;
551 finish();
552
553 if (!id) {
554 _skippedAfter = 0;
555 } else {
556 _skippedAfter = std::nullopt;
557 }
558 _skippedBefore = std::nullopt;
559 _list.clear();
560 if (processMessagesIsEmpty(result)) {
561 _fullCount = _skippedBefore = _skippedAfter = 0;
562 } else if (id) {
563 Assert(!_list.empty());
564 if (_list.front() <= id) {
565 _skippedAfter = 0;
566 } else if (_list.back() >= id) {
567 _skippedBefore = 0;
568 }
569 }
570 checkReadTillEnd();
571 }).fail([=] {
572 _beforeId = 0;
573 _loadingAround = std::nullopt;
574 finish();
575 }).send();
576 };
577 _loadingAround = id;
578 _beforeId = histories().sendRequest(
579 _history,
580 Histories::RequestType::History,
581 send);
582}
583
584void RepliesList::loadBefore() {
585 Expects(!_list.empty());

Callers

nothing calls this directly

Calls 15

MTP_longFunction · 0.85
apiMethod · 0.80
frontMethod · 0.80
MTP_intFunction · 0.70
finishFunction · 0.50
cancelRequestMethod · 0.45
sendMethod · 0.45
failMethod · 0.45
doneMethod · 0.45
requestMethod · 0.45
sessionMethod · 0.45
inputMethod · 0.45

Tested by

no test coverage detected