mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
detect if user has patchmatch enabled
This commit is contained in:
parent
fba25792f9
commit
d6c914eedc
@ -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')}
|
||||
|
@ -219,6 +219,9 @@ export const systemSlice = createSlice({
|
||||
progressImageSet(state, action: PayloadAction<ProgressImage | null>) {
|
||||
state.progressImage = action.payload;
|
||||
},
|
||||
setAvailableInfillMethods(state, action: PayloadAction<InfillMethod[]>) {
|
||||
state.infillMethods = action.payload;
|
||||
},
|
||||
},
|
||||
extraReducers(builder) {
|
||||
/**
|
||||
@ -451,6 +454,7 @@ export const {
|
||||
shouldAntialiasProgressImageChanged,
|
||||
languageChanged,
|
||||
progressImageSet,
|
||||
setAvailableInfillMethods,
|
||||
} = systemSlice.actions;
|
||||
|
||||
export default systemSlice.reducer;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { api } from '..';
|
||||
import { AppVersion } from '../types';
|
||||
import { AppVersion, AppConfig } from '../types';
|
||||
|
||||
export const appInfoApi = api.injectEndpoints({
|
||||
endpoints: (build) => ({
|
||||
@ -9,7 +9,13 @@ export const appInfoApi = api.injectEndpoints({
|
||||
method: 'GET',
|
||||
}),
|
||||
}),
|
||||
getAppConfig: build.query<AppConfig, void>({
|
||||
query: () => ({
|
||||
url: `app/config`,
|
||||
method: 'GET',
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const { useGetAppVersionQuery } = appInfoApi;
|
||||
export const { useGetAppVersionQuery, useGetAppConfigQuery } = appInfoApi;
|
||||
|
3653
invokeai/frontend/web/src/services/api/schema.d.ts
vendored
3653
invokeai/frontend/web/src/services/api/schema.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,7 @@ type TypeReq<T> = O.Required<T, 'type'>;
|
||||
|
||||
// App Info
|
||||
export type AppVersion = components['schemas']['AppVersion'];
|
||||
export type AppConfig = components['schemas']['AppConfig'];
|
||||
|
||||
// Images
|
||||
export type ImageDTO = components['schemas']['ImageDTO'];
|
||||
|
Loading…
Reference in New Issue
Block a user