fix is_disable_switch_model

This commit is contained in:
Qing
2022-11-25 08:55:10 +08:00
parent d44dd8822c
commit f7d7e89197
4 changed files with 42 additions and 18 deletions

View File

@@ -1,7 +1,13 @@
import React, { ReactNode, useEffect, useState } from 'react'
import { useRecoilState } from 'recoil'
import { useRecoilState, useRecoilValue } from 'recoil'
import { getIsDisableModelSwitch } from '../../adapters/inpainting'
import { AIModel, CV2Flag, SDSampler, settingState } from '../../store/Atoms'
import {
AIModel,
CV2Flag,
isDisableModelSwitchState,
SDSampler,
settingState,
} from '../../store/Atoms'
import Selector from '../shared/Selector'
import { Switch, SwitchThumb } from '../shared/Switch'
import Tooltip from '../shared/Tooltip'
@@ -11,18 +17,7 @@ import SettingBlock from './SettingBlock'
function ModelSettingBlock() {
const [setting, setSettingState] = useRecoilState(settingState)
const [isDisableModelSwitch, setIsDisableModelSwitch] = useState(false)
useEffect(() => {
const fetchData = async () => {
const isDisable: string = await getIsDisableModelSwitch().then(res =>
res.text()
)
setIsDisableModelSwitch(isDisable === 'true')
}
fetchData()
}, [])
const isDisableModelSwitch = useRecoilValue(isDisableModelSwitchState)
const onModelChange = (value: AIModel) => {
setSettingState(old => {