remove unnecesary usestate

This commit is contained in:
Hailey
2024-04-24 10:27:09 -07:00
parent 65b689d4af
commit ace0cb3ac9
+1 -6
View File
@@ -556,8 +556,6 @@ export function SearchScreen(
React.useState<AppBskyActorDefs.ProfileViewBasic[]>() React.useState<AppBskyActorDefs.ProfileViewBasic[]>()
const [inputIsFocused, setInputIsFocused] = React.useState(false) const [inputIsFocused, setInputIsFocused] = React.useState(false)
const [showAutocompleteResults, setShowAutocompleteResults] =
React.useState(false)
const [searchHistory, setSearchHistory] = React.useState<string[]>([]) const [searchHistory, setSearchHistory] = React.useState<string[]>([])
if (q !== queryTerm) { if (q !== queryTerm) {
@@ -603,7 +601,6 @@ export function SearchScreen(
const onPressCancelSearch = React.useCallback(() => { const onPressCancelSearch = React.useCallback(() => {
scrollToTopWeb() scrollToTopWeb()
setShowAutocompleteResults(false)
if (inputIsFocused) { if (inputIsFocused) {
setSearchText(queryTerm) setSearchText(queryTerm)
@@ -621,7 +618,6 @@ export function SearchScreen(
const onChangeText = React.useCallback(async (text: string) => { const onChangeText = React.useCallback(async (text: string) => {
scrollToTopWeb() scrollToTopWeb()
setSearchText(text) setSearchText(text)
setShowAutocompleteResults(text.length > 0)
}, []) }, [])
const updateSearchHistory = React.useCallback( const updateSearchHistory = React.useCallback(
@@ -650,7 +646,6 @@ export function SearchScreen(
const onSubmit = React.useCallback(() => { const onSubmit = React.useCallback(() => {
scrollToTopWeb() scrollToTopWeb()
setShowAutocompleteResults(false)
updateSearchHistory(searchText) updateSearchHistory(searchText)
setQueryTerm(searchText) setQueryTerm(searchText)
@@ -795,7 +790,7 @@ export function SearchScreen(
)} )}
</CenteredView> </CenteredView>
{showAutocompleteResults ? ( {inputIsFocused && searchText.length > 0 ? (
<> <>
{/* TODO avoid showing spinner if we have any previous results -hailey */} {/* TODO avoid showing spinner if we have any previous results -hailey */}
{(searchText && !autocompleteData) || !moderationOpts ? ( {(searchText && !autocompleteData) || !moderationOpts ? (