Skip to content

Commit

Permalink
fix: model dropdown search result always show downloaded models first (
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur authored and louis-jan committed Jul 12, 2024
1 parent c54642a commit e12549b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions web/containers/ModelDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,23 @@ const ModelDropdown = ({
)
}
})
.sort((a, b) => a.name.localeCompare(b.name)),
[configuredModels, searchText, searchFilter]
.sort((a, b) => a.name.localeCompare(b.name))
.sort((a, b) => {
const aInDownloadedModels = downloadedModels.some(
(item) => item.id === a.id
)
const bInDownloadedModels = downloadedModels.some(
(item) => item.id === b.id
)
if (aInDownloadedModels && !bInDownloadedModels) {
return -1
} else if (!aInDownloadedModels && bInDownloadedModels) {
return 1
} else {
return 0
}
}),
[configuredModels, searchText, searchFilter, downloadedModels]
)

useEffect(() => {
Expand Down

0 comments on commit e12549b

Please sign in to comment.