fix(SelectModelPopup): memoize adapted models to avoid unnecessary updates (#11506)

fix(SelectModelPopup): memoize adapted models to avoid unnecessary update
This commit is contained in:
Phantom 2025-11-27 22:22:04 +08:00 committed by GitHub
parent 1746e8b21f
commit 0d12b5fbc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -57,7 +57,7 @@ const PopupContainer: React.FC<Props> = ({ model, apiFilter, modelFilter, showTa
const [_searchText, setSearchText] = useState('') const [_searchText, setSearchText] = useState('')
const searchText = useDeferredValue(_searchText) const searchText = useDeferredValue(_searchText)
const { models, isLoading } = useApiModels(apiFilter) const { models, isLoading } = useApiModels(apiFilter)
const adaptedModels = models.map((model) => apiModelAdapter(model)) const adaptedModels = useMemo(() => models.map((model) => apiModelAdapter(model)), [models])
// 当前选中的模型ID // 当前选中的模型ID
const currentModelId = model ? model.id : '' const currentModelId = model ? model.id : ''