detect if user has patchmatch enabled

This commit is contained in:
Mary Hipp
2023-07-12 11:56:40 -04:00
committed by psychedelicious
parent fba25792f9
commit d6c914eedc
5 changed files with 2098 additions and 1589 deletions

View File

@ -6,8 +6,10 @@ import { generationSelector } from 'features/parameters/store/generationSelector
import { setInfillMethod } from 'features/parameters/store/generationSlice';
import { systemSelector } from 'features/system/store/systemSelectors';
import { memo, useCallback } from 'react';
import { memo, useCallback, useEffect, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useGetAppConfigQuery } from '../../../../../../services/api/endpoints/appInfo';
import { setAvailableInfillMethods } from '../../../../../system/store/systemSlice';
const selector = createSelector(
[generationSelector, systemSelector],
@ -27,6 +29,8 @@ const ParamInfillMethod = () => {
const dispatch = useAppDispatch();
const { infillMethod, infillMethods } = useAppSelector(selector);
const { data: appConfigData } = useGetAppConfigQuery();
const { t } = useTranslation();
const handleChange = useCallback(
@ -36,6 +40,19 @@ const ParamInfillMethod = () => {
[dispatch]
);
useEffect(() => {
if (!appConfigData) return;
if (!appConfigData.patchmatch_enabled) {
const filteredMethods = infillMethods.filter(
(method) => method !== 'patchmatch'
);
dispatch(setAvailableInfillMethods(filteredMethods));
dispatch(setInfillMethod(filteredMethods[0]));
} else {
dispatch(setInfillMethod('patchmatch'));
}
}, [appConfigData, infillMethods, dispatch]);
return (
<IAIMantineSelect
label={t('parameters.infillMethod')}