fix: model download state is not updated accordingly
This commit is contained in:
parent
38b2e5e7a2
commit
c5d4163869
@ -105,7 +105,7 @@ export default function EventHandler({ children }: { children: ReactNode }) {
|
||||
|
||||
function handleDownloadSuccess(state: any) {
|
||||
if (state && state.fileName && state.success === true) {
|
||||
state.fileName = state.fileName.replace('models/', '')
|
||||
state.fileName = state.fileName.split('/').pop() ?? ''
|
||||
setDownloadStateSuccess(state.fileName)
|
||||
const model = models.find((e) => e.id === state.fileName)
|
||||
if (model)
|
||||
|
||||
@ -27,6 +27,11 @@ export default function EventListenerWrapper({ children }: PropsWithChildren) {
|
||||
const { setDownloadedModels, downloadedModels } = useGetDownloadedModels()
|
||||
const { setDownloadState, setDownloadStateSuccess, setDownloadStateFailed } =
|
||||
useDownloadState()
|
||||
const downloadedModelRef = useRef(downloadedModels)
|
||||
|
||||
useEffect(() => {
|
||||
downloadedModelRef.current = downloadedModels
|
||||
}, [downloadedModels])
|
||||
|
||||
useEffect(() => {
|
||||
if (window && window.electronAPI) {
|
||||
@ -60,7 +65,7 @@ export default function EventListenerWrapper({ children }: PropsWithChildren) {
|
||||
.get<ModelPlugin>(PluginType.Model)
|
||||
?.saveModel(model)
|
||||
.then(() => {
|
||||
setDownloadedModels([...downloadedModels, model])
|
||||
setDownloadedModels([...downloadedModelRef.current, model])
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user