chore: my models search box css issue (#4984)
This commit is contained in:
parent
75d3dd2de0
commit
dc9750ecb4
@ -5,22 +5,12 @@ import { SearchIcon } from 'lucide-react'
|
||||
|
||||
import { useDebouncedCallback } from 'use-debounce'
|
||||
|
||||
import {
|
||||
useGetModelSources,
|
||||
useModelSourcesMutation,
|
||||
} from '@/hooks/useModelSource'
|
||||
|
||||
import Spinner from '../Loader/Spinner'
|
||||
|
||||
type Props = {
|
||||
onSearchLocal?: (searchText: string) => void
|
||||
}
|
||||
|
||||
const ModelSearch = ({ onSearchLocal }: Props) => {
|
||||
const [searchText, setSearchText] = useState('')
|
||||
const [isSearching, setSearching] = useState(false)
|
||||
const { mutate } = useGetModelSources()
|
||||
const { addModelSource } = useModelSourcesMutation()
|
||||
const inputRef = useRef<HTMLInputElement | null>(null)
|
||||
const debounced = useDebouncedCallback(async () => {
|
||||
if (searchText.indexOf('/') === -1) {
|
||||
@ -30,16 +20,6 @@ const ModelSearch = ({ onSearchLocal }: Props) => {
|
||||
}
|
||||
// Attempt to search local
|
||||
onSearchLocal?.(searchText)
|
||||
|
||||
setSearching(true)
|
||||
// Attempt to search model source
|
||||
addModelSource(searchText)
|
||||
.then(() => mutate())
|
||||
.then(() => onSearchLocal?.(searchText))
|
||||
.catch((e) => {
|
||||
console.debug(e)
|
||||
})
|
||||
.finally(() => setSearching(false))
|
||||
}, 300)
|
||||
|
||||
const onSearchChanged = useCallback(
|
||||
@ -70,20 +50,14 @@ const ModelSearch = ({ onSearchLocal }: Props) => {
|
||||
return (
|
||||
<Input
|
||||
ref={inputRef}
|
||||
prefixIcon={
|
||||
isSearching ? (
|
||||
<Spinner size={16} strokeWidth={2} />
|
||||
) : (
|
||||
<SearchIcon size={16} />
|
||||
)
|
||||
}
|
||||
placeholder="Search or enter Hugging Face URL"
|
||||
prefixIcon={<SearchIcon size={16} />}
|
||||
placeholder="Search models..."
|
||||
onChange={onSearchChanged}
|
||||
onKeyDown={onKeyDown}
|
||||
value={searchText}
|
||||
clearable={searchText.length > 0}
|
||||
onClear={onClear}
|
||||
className="border-0 bg-[hsla(var(--app-bg))]"
|
||||
className="border-1 bg-[hsla(var(--app-bg))]"
|
||||
onClick={() => {
|
||||
onSearchLocal?.(inputRef.current?.value ?? '')
|
||||
}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user