refresh local models in real-time (#98)
This commit is contained in:
parent
7210a7481e
commit
2d545604f4
@ -1,10 +1,10 @@
|
|||||||
import React, { FC, useEffect } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Page } from '../components/Page';
|
import { Page } from '../components/Page';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import commonStore from '../stores/commonStore';
|
import commonStore from '../stores/commonStore';
|
||||||
import { Divider, Field, ProgressBar } from '@fluentui/react-components';
|
import { Divider, Field, ProgressBar } from '@fluentui/react-components';
|
||||||
import { bytesToGb, bytesToKb, bytesToMb, refreshLocalModels } from '../utils';
|
import { bytesToGb, bytesToKb, bytesToMb } from '../utils';
|
||||||
import { ToolTipButton } from '../components/ToolTipButton';
|
import { ToolTipButton } from '../components/ToolTipButton';
|
||||||
import { Folder20Regular, Pause20Regular, Play20Regular } from '@fluentui/react-icons';
|
import { Folder20Regular, Pause20Regular, Play20Regular } from '@fluentui/react-icons';
|
||||||
import { AddToDownloadList, OpenFileFolder, PauseDownload } from '../../wailsjs/go/backend_golang/App';
|
import { AddToDownloadList, OpenFileFolder, PauseDownload } from '../../wailsjs/go/backend_golang/App';
|
||||||
@ -23,12 +23,6 @@ export type DownloadStatus = {
|
|||||||
|
|
||||||
export const Downloads: FC = observer(() => {
|
export const Downloads: FC = observer(() => {
|
||||||
const { t } = useTranslation();
|
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();
|
let displayList = commonStore.downloadList.slice();
|
||||||
const downloadListNames = displayList.map(s => s.name);
|
const downloadListNames = displayList.map(s => s.name);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import commonStore, { Platform } from './stores/commonStore';
|
import commonStore, { Platform } from './stores/commonStore';
|
||||||
import { GetPlatform, ListDirFiles, ReadJson } from '../wailsjs/go/backend_golang/App';
|
import { GetPlatform, ListDirFiles, ReadJson } from '../wailsjs/go/backend_golang/App';
|
||||||
import { Cache, checkUpdate, downloadProgramFiles, LocalConfig, refreshModels } from './utils';
|
import { Cache, checkUpdate, downloadProgramFiles, LocalConfig, refreshLocalModels, refreshModels } from './utils';
|
||||||
import { getStatus } from './apis';
|
import { getStatus } from './apis';
|
||||||
import { EventsOn } from '../wailsjs/runtime';
|
import { EventsOn } from '../wailsjs/runtime';
|
||||||
import manifest from '../../manifest.json';
|
import manifest from '../../manifest.json';
|
||||||
@ -18,6 +18,7 @@ export async function startup() {
|
|||||||
EventsOn('wslerr', (e) => {
|
EventsOn('wslerr', (e) => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
});
|
});
|
||||||
|
initLocalModelsNotify();
|
||||||
initLoraModels();
|
initLoraModels();
|
||||||
|
|
||||||
initPresets();
|
initPresets();
|
||||||
@ -109,3 +110,10 @@ async function initLoraModels() {
|
|||||||
refreshLoraModels();
|
refreshLoraModels();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function initLocalModelsNotify() {
|
||||||
|
EventsOn('fsnotify', (data: string) => {
|
||||||
|
if (data.includes('models') && !data.includes('lora-models'))
|
||||||
|
refreshLocalModels({ models: commonStore.modelSourceList }, false); //TODO fix bug that only add models
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user