fix: hub ui no result search found (#4739)

This commit is contained in:
Faisal Amir 2025-02-26 19:06:46 +07:00 committed by GitHub
parent d7329c7719
commit 36a14600ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 54 additions and 32 deletions

View File

@ -5,11 +5,20 @@ import ModelItem from '@/screens/Hub/ModelList/ModelItem'
type Props = { type Props = {
models: ModelSource[] models: ModelSource[]
onSelectedModel: (model: ModelSource) => void onSelectedModel: (model: ModelSource) => void
filterOption?: string
} }
const ModelList = ({ models, onSelectedModel }: Props) => { const ModelList = ({ models, onSelectedModel, filterOption }: Props) => {
return ( return (
<div className="w-full"> <div className="w-full">
{models.length === 0 && filterOption === 'on-device' ? (
<div className="my-4 p-2 text-center">
<span className="text-[hsla(var(--text-tertiary))]">
No results found
</span>
</div>
) : (
<>
{models.map((model) => ( {models.map((model) => (
<ModelItem <ModelItem
key={model.id} key={model.id}
@ -17,6 +26,8 @@ const ModelList = ({ models, onSelectedModel }: Props) => {
onSelectedModel={() => onSelectedModel(model)} onSelectedModel={() => onSelectedModel(model)}
/> />
))} ))}
</>
)}
</div> </div>
) )
} }

View File

@ -404,9 +404,17 @@ const HubScreen = () => {
<div <div
className={twMerge( className={twMerge(
'invisible absolute mt-2 w-full overflow-hidden rounded-lg border border-[hsla(var(--app-border))] bg-[hsla(var(--app-bg))] shadow-lg', 'invisible absolute mt-2 w-full overflow-hidden rounded-lg border border-[hsla(var(--app-border))] bg-[hsla(var(--app-bg))] shadow-lg',
searchedModels.length > 0 && 'visible' searchValue.length > 0 && 'visible'
)} )}
> >
{searchedModels.length === 0 ? (
<div className="p-2 text-center">
<span className="text-[hsla(var(--text-tertiary))]">
No results found
</span>
</div>
) : (
<>
{searchedModels.map((model) => ( {searchedModels.map((model) => (
<div <div
key={model.id} key={model.id}
@ -432,6 +440,8 @@ const HubScreen = () => {
</span> </span>
</div> </div>
))} ))}
</>
)}
</div> </div>
</div> </div>
</div> </div>
@ -523,6 +533,7 @@ const HubScreen = () => {
<ModelList <ModelList
models={sortedModels} models={sortedModels}
onSelectedModel={(model) => setSelectedModel(model)} onSelectedModel={(model) => setSelectedModel(model)}
filterOption={filterOption}
/> />
)} )}
{(filterOption === 'cloud' || filterOption === 'all') && ( {(filterOption === 'cloud' || filterOption === 'all') && (