| 2893 | } |
| 2894 | |
| 2895 | void 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 | |
| 2936 | void Widget::searchMore() { |
| 2937 | const auto process = currentSearchProcess(); |
nothing calls this directly
no test coverage detected