| 4054 | } |
| 4055 | |
| 4056 | void InnerWidget::searchReceived( |
| 4057 | std::vector<not_null<HistoryItem*>> messages, |
| 4058 | HistoryItem *inject, |
| 4059 | SearchRequestType type, |
| 4060 | int fullCount) { |
| 4061 | _searchWaiting = false; |
| 4062 | _searchLoading = false; |
| 4063 | |
| 4064 | const auto uniquePeers = uniqueSearchResults(); |
| 4065 | const auto withPreview = _searchWithPostsPreview; |
| 4066 | const auto toPreview = withPreview && type.posts; |
| 4067 | if (type.start && !type.migrated && (!withPreview || !type.posts)) { |
| 4068 | clearSearchResults(false); |
| 4069 | } |
| 4070 | if (!withPreview || toPreview) { |
| 4071 | clearPreviewResults(); |
| 4072 | } |
| 4073 | |
| 4074 | const auto globalSearch = (_searchState.tab == ChatSearchTab::MyMessages) |
| 4075 | || (_searchState.tab == ChatSearchTab::PublicPosts); |
| 4076 | const auto key = globalSearch |
| 4077 | ? Key() |
| 4078 | : (!_openedForum || _searchState.inChat.topic()) |
| 4079 | ? _searchState.inChat |
| 4080 | : Key(_openedForum->history()); |
| 4081 | if (inject |
| 4082 | && (globalSearch |
| 4083 | || !_searchState.inChat |
| 4084 | || inject->history() == _searchState.inChat.history())) { |
| 4085 | Assert(_searchResults.empty()); |
| 4086 | Assert(!toPreview); |
| 4087 | const auto index = int(_searchResults.size()); |
| 4088 | _searchResults.push_back( |
| 4089 | std::make_unique<FakeRow>( |
| 4090 | key, |
| 4091 | inject, |
| 4092 | [=] { repaintSearchResult(index); })); |
| 4093 | trackResultsHistory(inject->history()); |
| 4094 | ++fullCount; |
| 4095 | } |
| 4096 | auto &results = toPreview ? _previewResults : _searchResults; |
| 4097 | for (const auto &item : messages) { |
| 4098 | const auto history = item->history(); |
| 4099 | if (toPreview || !uniquePeers || !hasHistoryInResults(history)) { |
| 4100 | const auto index = int(results.size()); |
| 4101 | const auto repaint = toPreview |
| 4102 | ? Fn<void()>([=] { repaintSearchResult(index); }) |
| 4103 | : [=] { repaintPreviewResult(index); }; |
| 4104 | results.push_back( |
| 4105 | std::make_unique<FakeRow>(key, item, repaint)); |
| 4106 | trackResultsHistory(history); |
| 4107 | if (!toPreview && uniquePeers && !history->unreadCountKnown()) { |
| 4108 | history->owner().histories().requestDialogEntry(history); |
| 4109 | } else if (toPreview && results.size() >= kPreviewPostsLimit) { |
| 4110 | break; |
| 4111 | } |
| 4112 | } |
| 4113 | } |
nothing calls this directly
no test coverage detected