reset on unmount

This commit is contained in:
Mary Hipp 2023-08-28 11:03:15 -04:00
parent 56be24b0e4
commit 6233b0d70d
2 changed files with 6 additions and 9 deletions

View File

@ -29,14 +29,12 @@ 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);
@ -53,12 +51,6 @@ 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');
@ -74,6 +66,12 @@ dispatch(api.util.resetApiState());
handlePreselectedImage(selectedImage); handlePreselectedImage(selectedImage);
}, [handlePreselectedImage, selectedImage]); }, [handlePreselectedImage, selectedImage]);
useEffect(() => {
return () => {
dispatch(api.util.resetApiState());
};
});
return ( return (
<ErrorBoundary <ErrorBoundary
onReset={handleReset} onReset={handleReset}

View File

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