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

Method requestTopics

Telegram/SourceFiles/data/data_forum.cpp:168–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168void Forum::requestTopics() {
169 if (_topicsList.loaded() || _requestId) {
170 return;
171 }
172 const auto firstLoad = !_offset.date;
173 const auto loadCount = firstLoad ? kTopicsFirstLoad : kTopicsPerPage;
174 _requestId = session().api().request(MTPmessages_GetForumTopics(
175 MTP_flags(0),
176 peer()->input(),
177 MTPstring(), // q
178 MTP_int(_offset.date),
179 MTP_int(_offset.id),
180 MTP_int(_offset.topicId),
181 MTP_int(loadCount)
182 )).done([=](const MTPmessages_ForumTopics &result) {
183 const auto previousOffset = _offset;
184 applyReceivedTopics(result, _offset);
185 const auto &list = result.data().vtopics().v;
186 if (list.isEmpty()
187 || list.size() == result.data().vcount().v
188 || (_offset == previousOffset)) {
189 _topicsList.setLoaded();
190 }
191 _requestId = 0;
192 _chatsListChanges.fire({});
193 if (_topicsList.loaded()) {
194 _chatsListLoadedEvents.fire({});
195 }
196 reorderLastTopics();
197 requestSomeStale();
198 }).fail([=](const MTP::Error &error) {
199 _requestId = 0;
200 _topicsList.setLoaded();
201 if (error.type() == u"CHANNEL_FORUM_MISSING"_q && channel()) {
202 const auto flags = channel()->flags() & ~ChannelDataFlag::Forum;
203 channel()->setFlags(flags);
204 }
205 }).send();
206}
207
208void Forum::applyTopicDeleted(MsgId rootId) {
209 _topicsDeleted.emplace(rootId);

Callers 3

loadMoreRowsMethod · 0.80
WidgetMethod · 0.80
loadMoreMethod · 0.80

Calls 15

MTP_flagsFunction · 0.85
apiMethod · 0.80
MTP_intFunction · 0.70
loadedMethod · 0.45
sendMethod · 0.45
failMethod · 0.45
doneMethod · 0.45
requestMethod · 0.45
inputMethod · 0.45
dataMethod · 0.45
isEmptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected