remove unnecesary usestate
This commit is contained in:
@@ -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 ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user