| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | import { useEffect, useState } from 'react' |
| 2 | 2 | import { addQueryArg } from '../utils/restAPI' |
| 3 | +import { TIMEOUTS } from '../../../tests/e2e/helpers/constants' | |
| 3 | 4 | import { useRestAPI } from './useRestAPI' |
| 4 | 5 | import type { DuplicateReport, DuplicateSearchResponse } from '../types/Feedback' |
| 5 | 6 | |
| 6 | 7 | /** Shortest title worth looking for existing reports of. */ |
| @@ -5,11 +6,8 @@ | ||
| 5 | 6 | |
| 6 | 7 | /** Shortest title worth looking for existing reports of. */ |
| 7 | 8 | const MIN_SEARCH_LENGTH = 6 |
| 8 | 9 | |
| 9 | -/** How long to wait after the last keystroke before searching. */ | |
| 10 | -const SEARCH_DEBOUNCE_MS = 600 | |
| 11 | - | |
| 12 | 10 | /** |
| 13 | 11 | * Offer reports already filed about whatever is being described, so the same problem is |
| 14 | 12 | * not reported twice. A cloud that cannot answer leaves the list empty rather than |
| 15 | 13 | * interrupting the report being written. |
| @@ -31,9 +29,9 @@ | ||
| 31 | 29 | const timer = setTimeout(() => { |
| 32 | 30 | api.get<DuplicateSearchResponse>(addQueryArg({ url: searchUrl, name: 'q', value: query })) |
| 33 | 31 | .then(data => active && setDuplicates(data.results)) |
| 34 | 32 | .catch(() => active && setDuplicates([])) |
| 35 | - }, SEARCH_DEBOUNCE_MS) | |
| 33 | + }, TIMEOUTS.VERY_SHORT) | |
| 36 | 34 | |
| 37 | 35 | return () => { |
| 38 | 36 | active = false |
| 39 | 37 | clearTimeout(timer) |