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

Method loadAround

Telegram/SourceFiles/data/data_saved_sublist.cpp:1144–1225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1142}
1143
1144void SavedSublist::loadAround(MsgId id) {
1145 if (_loadingAround && *_loadingAround == id) {
1146 _loadingAroundRetry = id;
1147 return;
1148 }
1149 _loadingAroundRetry = std::nullopt;
1150 histories().cancelRequest(base::take(_beforeId));
1151 histories().cancelRequest(base::take(_afterId));
1152
1153 const auto send = [=](Fn<void()> finish) {
1154 using Flag = MTPmessages_GetSavedHistory::Flag;
1155 const auto parentChat = _parent->parentChat();
1156 return session().api().request(MTPmessages_GetSavedHistory(
1157 MTP_flags(parentChat ? Flag::f_parent_peer : Flag(0)),
1158 parentChat ? parentChat->input() : MTPInputPeer(),
1159 sublistPeer()->input(),
1160 MTP_int(id), // offset_id
1161 MTP_int(0), // offset_date
1162 MTP_int(id ? (-kMessagesPerPage / 2) : 0), // add_offset
1163 MTP_int(kMessagesPerPage), // limit
1164 MTP_int(0), // max_id
1165 MTP_int(0), // min_id
1166 MTP_long(0)) // hash
1167 ).done([=](const MTPmessages_Messages &result) {
1168 _beforeId = 0;
1169 _loadingAround = std::nullopt;
1170 finish();
1171
1172 if (!id) {
1173 _skippedAfter = 0;
1174 } else {
1175 _skippedAfter = std::nullopt;
1176 }
1177 _skippedBefore = std::nullopt;
1178 _list.clear();
1179 if (processMessagesIsEmpty(result)) {
1180 _fullCount = _skippedBefore = _skippedAfter = 0;
1181 if (!_parent->parentChat()
1182 && !_chatListMessage.value_or(nullptr)) {
1183 if (isPinnedDialog(FilterId())) {
1184 _restorePinnedWhenNonEmpty = true;
1185 owner().setChatPinned(this, FilterId(), false);
1186 }
1187 setLastServerMessage(nullptr);
1188 updateChatListExistence();
1189 }
1190 } else if (id) {
1191 Assert(!_list.empty());
1192 if (_list.front() <= id) {
1193 _skippedAfter = 0;
1194 } else if (_list.back() >= id) {
1195 _skippedBefore = 0;
1196 }
1197 } else if (!_parent->parentChat()
1198 && !_chatListMessage.value_or(nullptr)) {
1199 Assert(!_list.empty());
1200 applyMaybeLast(owner().message(
1201 owningHistory()->peer,

Callers

nothing calls this directly

Calls 15

MTP_flagsFunction · 0.85
MTP_longFunction · 0.85
apiMethod · 0.80
value_orMethod · 0.80
setChatPinnedMethod · 0.80
frontMethod · 0.80
markUnsupportedMethod · 0.80
FlagEnum · 0.70
MTP_intFunction · 0.70
finishFunction · 0.50
cancelRequestMethod · 0.45
parentChatMethod · 0.45

Tested by

no test coverage detected