Unify codepaths
This commit is contained in:
@@ -580,18 +580,30 @@ export function SearchScreen(
|
|||||||
[searchHistory, setSearchHistory],
|
[searchHistory, setSearchHistory],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onSubmit = React.useCallback(() => {
|
const navigateToItem = React.useCallback(
|
||||||
|
(item: string) => {
|
||||||
scrollToTopWeb()
|
scrollToTopWeb()
|
||||||
setInputIsFocused(false)
|
setInputIsFocused(false)
|
||||||
updateSearchHistory(searchText)
|
updateSearchHistory(item)
|
||||||
|
|
||||||
if (isWeb) {
|
if (isWeb) {
|
||||||
navigation.push('Search', {q: searchText})
|
navigation.push('Search', {q: item})
|
||||||
} else {
|
} else {
|
||||||
textInput.current?.blur()
|
textInput.current?.blur()
|
||||||
navigation.setParams({q: searchText})
|
navigation.setParams({q: item})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[updateSearchHistory, navigation],
|
||||||
|
)
|
||||||
|
|
||||||
|
const onSubmit = React.useCallback(() => {
|
||||||
|
navigateToItem(searchText)
|
||||||
|
}, [navigateToItem, searchText])
|
||||||
|
|
||||||
|
const handleHistoryItemClick = (item: string) => {
|
||||||
|
setSearchText(item)
|
||||||
|
navigateToItem(item)
|
||||||
}
|
}
|
||||||
}, [navigation, searchText, updateSearchHistory])
|
|
||||||
|
|
||||||
const onSoftReset = React.useCallback(() => {
|
const onSoftReset = React.useCallback(() => {
|
||||||
scrollToTopWeb()
|
scrollToTopWeb()
|
||||||
@@ -610,17 +622,6 @@ export function SearchScreen(
|
|||||||
}, [onSoftReset, setMinimalShellMode]),
|
}, [onSoftReset, setMinimalShellMode]),
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleHistoryItemClick = (item: string) => {
|
|
||||||
setInputIsFocused(false)
|
|
||||||
setSearchText(item)
|
|
||||||
textInput.current?.blur()
|
|
||||||
if (isWeb) {
|
|
||||||
navigation.push('Search', {q: item})
|
|
||||||
} else {
|
|
||||||
navigation.setParams({q: item})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleRemoveHistoryItem = (itemToRemove: string) => {
|
const handleRemoveHistoryItem = (itemToRemove: string) => {
|
||||||
const updatedHistory = searchHistory.filter(item => item !== itemToRemove)
|
const updatedHistory = searchHistory.filter(item => item !== itemToRemove)
|
||||||
setSearchHistory(updatedHistory)
|
setSearchHistory(updatedHistory)
|
||||||
|
|||||||
Reference in New Issue
Block a user