This commit is contained in:
Dan Abramov
2024-04-27 02:20:08 +01:00
parent 812dc372b4
commit 347d573b75
+7 -2
View File
@@ -559,8 +559,11 @@ export function SearchScreen(
const updateSearchHistory = React.useCallback(
async (newQuery: string) => {
newQuery = newQuery.trim()
if (newQuery && !searchHistory.includes(newQuery)) {
let newHistory = [newQuery, ...searchHistory]
if (newQuery) {
let newHistory = [
newQuery,
...searchHistory.filter(q => q !== newQuery),
]
if (newHistory.length > 5) {
newHistory = newHistory.slice(0, 5)
@@ -757,6 +760,8 @@ export function SearchScreen(
onPress={() => {
if (isWeb) {
setInputIsFocused(false)
} else {
textInput.current?.blur()
}
}}
/>