From b7e94aac02c6ce99e87dcf3256ee2ab0dd3a19d8 Mon Sep 17 00:00:00 2001 From: NamH Date: Fri, 16 Feb 2024 10:46:42 +0700 Subject: [PATCH] fix: disable gpu drop down box if there's no GPU ready (#2046) Signed-off-by: James Co-authored-by: James --- extensions/model-extension/src/index.ts | 8 ++++---- web/screens/Settings/Advanced/index.tsx | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/extensions/model-extension/src/index.ts b/extensions/model-extension/src/index.ts index 61a7db005..817794c74 100644 --- a/extensions/model-extension/src/index.ts +++ b/extensions/model-extension/src/index.ts @@ -434,20 +434,20 @@ export default class JanModelExtension extends ModelExtension { handleDesktopEvents() { if (window && window.electronAPI) { window.electronAPI.onFileDownloadUpdate( - async (_event: string, state: any | undefined) => { + async (_event: string, state: DownloadState | undefined) => { if (!state) return - state.downloadState = 'update' + state.downloadState = 'downloading' events.emit(DownloadEvent.onFileDownloadUpdate, state) } ) window.electronAPI.onFileDownloadError( - async (_event: string, state: any) => { + async (_event: string, state: DownloadState) => { state.downloadState = 'error' events.emit(DownloadEvent.onFileDownloadError, state) } ) window.electronAPI.onFileDownloadSuccess( - async (_event: string, state: any) => { + async (_event: string, state: DownloadState) => { state.downloadState = 'end' events.emit(DownloadEvent.onFileDownloadSuccess, state) } diff --git a/web/screens/Settings/Advanced/index.tsx b/web/screens/Settings/Advanced/index.tsx index 2d9f85712..43204d7c1 100644 --- a/web/screens/Settings/Advanced/index.tsx +++ b/web/screens/Settings/Advanced/index.tsx @@ -85,14 +85,14 @@ const Advanced = () => { useEffect(() => { const setUseGpuIfPossible = async () => { const settings = await readSettings() - setGpuEnabled(settings.run_mode === 'gpu') + setGpuEnabled(settings.run_mode === 'gpu' && gpuList.length > 0) setGpusInUse(settings.gpus_in_use || []) if (settings.gpus) { setGpuList(settings.gpus) } } setUseGpuIfPossible() - }, [readSettings]) + }, [readSettings, gpuList]) const clearLogs = async () => { if (await fs.existsSync(`file://logs`)) { @@ -254,7 +254,10 @@ const Advanced = () => {
-