reset api state when project changes

This commit is contained in:
Mary Hipp 2023-08-28 10:53:29 -04:00
parent a5fe6c8af6
commit 56be24b0e4
2 changed files with 10 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import { usePreselectedImage } from '../../features/parameters/hooks/usePreselec
import AppErrorBoundaryFallback from './AppErrorBoundaryFallback';
import GlobalHotkeys from './GlobalHotkeys';
import Toaster from './Toaster';
import { api } from '../../services/api';
const DEFAULT_CONFIG = {};
@ -28,12 +29,14 @@ interface Props {
imageName: string;
action: 'sendToImg2Img' | 'sendToCanvas' | 'useAllParameters';
};
projectId?: string;
}
const App = ({
config = DEFAULT_CONFIG,
headerComponent,
selectedImage,
projectId,
}: Props) => {
const language = useAppSelector(languageSelector);
@ -50,6 +53,12 @@ const App = ({
i18n.changeLanguage(language);
}, [language]);
useEffect(() => {
if (projectId) {
dispatch(api.util.resetApiState());
}
}, [projectId, dispatch]);
useEffect(() => {
if (size(config)) {
logger.info({ config }, 'Received config');

View File

@ -90,6 +90,7 @@ const InvokeAIUI = ({
config={config}
headerComponent={headerComponent}
selectedImage={selectedImage}
projectId={projectId}
/>
</AppDndContext>
</ThemeLocaleProvider>