| 199 | } |
| 200 | |
| 201 | bool SearchAPI::SearchInViewport(ViewportSearchParams params) |
| 202 | { |
| 203 | // Save params first for the PokeSearchInViewport function. |
| 204 | m_viewportParams = params; |
| 205 | |
| 206 | SearchParams p; |
| 207 | p.m_query = std::move(params.m_query); |
| 208 | p.m_inputLocale = std::move(params.m_inputLocale); |
| 209 | p.m_position = m_delegate.GetCurrentPosition(); |
| 210 | SetViewportIfPossible(p); // Search request will be delayed if viewport is not available. |
| 211 | p.m_maxNumResults = SearchParams::kDefaultNumResultsInViewport; |
| 212 | p.m_mode = Mode::Viewport; |
| 213 | p.m_suggestsEnabled = false; |
| 214 | p.m_needAddress = false; |
| 215 | p.m_needHighlighting = false; |
| 216 | p.m_categorialRequest = params.m_isCategory; |
| 217 | |
| 218 | if (params.m_timeout) |
| 219 | p.m_timeout = *params.m_timeout; |
| 220 | |
| 221 | if (params.m_onStarted) |
| 222 | { |
| 223 | p.m_onStarted = [this, onStarted = std::move(params.m_onStarted)]() mutable |
| 224 | { RunUITask([onStarted = std::move(onStarted)]() { onStarted(); }); }; |
| 225 | } |
| 226 | |
| 227 | p.m_onResults = ViewportSearchCallback(m_viewport, *this, std::move(params.m_onCompleted)); |
| 228 | |
| 229 | return Search(std::move(p), false /* forceSearch */); |
| 230 | } |
| 231 | |
| 232 | bool SearchAPI::SearchInDownloader(storage::DownloaderSearchParams params) |
| 233 | { |