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

View File

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