fix: GPU settings are not being persisted properly

This commit is contained in:
Louis 2024-11-12 15:59:09 +07:00
parent 1bd58e1327
commit 23cbeeedc3

View File

@ -189,7 +189,7 @@ const Advanced = () => {
* @param gpuId * @param gpuId
* @returns * @returns
*/ */
const handleGPUChange = (gpuId: string) => { const handleGPUChange = async (gpuId: string) => {
let updatedGpusInUse = [...gpusInUse] let updatedGpusInUse = [...gpusInUse]
if (updatedGpusInUse.includes(gpuId)) { if (updatedGpusInUse.includes(gpuId)) {
updatedGpusInUse = updatedGpusInUse.filter((id) => id !== gpuId) updatedGpusInUse = updatedGpusInUse.filter((id) => id !== gpuId)
@ -208,7 +208,7 @@ const Advanced = () => {
updatedGpusInUse.push(gpuId) updatedGpusInUse.push(gpuId)
} }
setGpusInUse(updatedGpusInUse) setGpusInUse(updatedGpusInUse)
saveSettings({ gpusInUse: updatedGpusInUse }) await saveSettings({ gpusInUse: updatedGpusInUse })
window.core?.api?.relaunch() window.core?.api?.relaunch()
} }
@ -306,8 +306,13 @@ const Advanced = () => {
}) })
} }
// Stop any running model to apply the changes // Stop any running model to apply the changes
if (e.target.checked !== gpuEnabled) if (e.target.checked !== gpuEnabled) {
stopModel().then(() => window.location.reload()) stopModel().finally(() => {
setTimeout(() => {
window.location.reload()
}, 300)
})
}
}} }}
/> />
} }