From 4112200b4c74e66242ebf78ad80433e13b237aed Mon Sep 17 00:00:00 2001 From: josc146 Date: Fri, 15 Sep 2023 16:25:04 +0800 Subject: [PATCH] revert(2d5456): refresh local models when download complete (for macOS) --- frontend/src/pages/Downloads.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/Downloads.tsx b/frontend/src/pages/Downloads.tsx index e5fd9bd..80991a0 100644 --- a/frontend/src/pages/Downloads.tsx +++ b/frontend/src/pages/Downloads.tsx @@ -1,10 +1,10 @@ -import React, { FC } from 'react'; +import React, { FC, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { Page } from '../components/Page'; import { observer } from 'mobx-react-lite'; import commonStore from '../stores/commonStore'; import { Divider, Field, ProgressBar } from '@fluentui/react-components'; -import { bytesToGb, bytesToKb, bytesToMb } from '../utils'; +import { bytesToGb, bytesToKb, bytesToMb, refreshLocalModels } from '../utils'; import { ToolTipButton } from '../components/ToolTipButton'; import { Folder20Regular, Pause20Regular, Play20Regular } from '@fluentui/react-icons'; import { AddToDownloadList, OpenFileFolder, PauseDownload } from '../../wailsjs/go/backend_golang/App'; @@ -23,6 +23,12 @@ export type DownloadStatus = { export const Downloads: FC = observer(() => { const { t } = useTranslation(); + const finishedModelsLen = commonStore.downloadList.filter((status) => status.done && status.name.endsWith('.pth')).length; + useEffect(() => { + if (finishedModelsLen > 0) + refreshLocalModels({ models: commonStore.modelSourceList }, false); + console.log('finishedModelsLen:', finishedModelsLen); + }, [finishedModelsLen]); let displayList = commonStore.downloadList.slice(); const downloadListNames = displayList.map(s => s.name);