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

Method searchTopics

Telegram/SourceFiles/dialogs/dialogs_widget.cpp:2895–2934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2893}
2894
2895void Widget::searchTopics() {
2896 if (_topicSearchRequest || _topicSearchFull) {
2897 return;
2898 }
2899 _api.request(base::take(_topicSearchRequest)).cancel();
2900 _topicSearchRequest = _api.request(MTPmessages_GetForumTopics(
2901 MTP_flags(MTPmessages_GetForumTopics::Flag::f_q),
2902 _openedForum->peer()->input(),
2903 MTP_string(_topicSearchQuery),
2904 MTP_int(_topicSearchOffsetDate),
2905 MTP_int(_topicSearchOffsetId),
2906 MTP_int(_topicSearchOffsetTopicId),
2907 MTP_int(kSearchPerPage)
2908 )).done([=](const MTPmessages_ForumTopics &result) {
2909 _topicSearchRequest = 0;
2910 const auto savedTopicId = _topicSearchOffsetTopicId;
2911 const auto byCreation = result.data().is_order_by_create_date();
2912 _openedForum->applyReceivedTopics(result, [&](
2913 not_null<Data::ForumTopic*> topic) {
2914 _topicSearchOffsetTopicId = topic->rootId();
2915 if (byCreation) {
2916 _topicSearchOffsetDate = topic->creationDate();
2917 if (const auto last = topic->lastServerMessage()) {
2918 _topicSearchOffsetId = last->id;
2919 }
2920 } else if (const auto last = topic->lastServerMessage()) {
2921 _topicSearchOffsetId = last->id;
2922 _topicSearchOffsetDate = last->date();
2923 }
2924 _inner->appendToFiltered(topic);
2925 });
2926 if (_topicSearchOffsetTopicId != savedTopicId) {
2927 _inner->refresh();
2928 } else {
2929 _topicSearchFull = true;
2930 }
2931 }).fail([=] {
2932 _topicSearchFull = true;
2933 }).send();
2934}
2935
2936void Widget::searchMore() {
2937 const auto process = currentSearchProcess();

Callers

nothing calls this directly

Calls 15

MTP_flagsFunction · 0.85
MTP_stringFunction · 0.85
applyReceivedTopicsMethod · 0.80
rootIdMethod · 0.80
creationDateMethod · 0.80
appendToFilteredMethod · 0.80
MTP_intFunction · 0.50
cancelMethod · 0.45
requestMethod · 0.45
sendMethod · 0.45
failMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected