mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
fix(ui): make sure schema has loaded before trying to load any workflows
This commit is contained in:
committed by
Mary Hipp Rogers
parent
549f4e9794
commit
0d86de0cb5
@@ -59,7 +59,7 @@ const App = ({ config = DEFAULT_CONFIG, studioInitAction }: Props) => {
|
||||
useSocketIO();
|
||||
useGlobalModifiersInit();
|
||||
useGlobalHotkeys();
|
||||
useGetOpenAPISchemaQuery();
|
||||
const { data: openApiData } = useGetOpenAPISchemaQuery();
|
||||
useSyncLoggingConfig();
|
||||
|
||||
const handleReset = useCallback(() => {
|
||||
@@ -83,7 +83,7 @@ const App = ({ config = DEFAULT_CONFIG, studioInitAction }: Props) => {
|
||||
dispatch(appStarted());
|
||||
}, [dispatch]);
|
||||
|
||||
useStudioInitAction(studioInitAction);
|
||||
useStudioInitAction(studioInitAction, !!openApiData);
|
||||
useStarterModelsToast();
|
||||
useSyncQueueStatus();
|
||||
useFocusRegionWatcher();
|
||||
|
||||
@@ -46,7 +46,7 @@ export type StudioInitAction =
|
||||
* - Use `getImageDTO` helper instead of `useGetImageDTO`
|
||||
* - Usee the `$imageViewer` atom instead of `useImageViewer`
|
||||
*/
|
||||
export const useStudioInitAction = (action?: StudioInitAction) => {
|
||||
export const useStudioInitAction = (action?: StudioInitAction, schemaLoaded?: boolean) => {
|
||||
useAssertSingleton('useStudioInitAction');
|
||||
const { t } = useTranslation();
|
||||
// Use a ref to ensure that we only perform the action once
|
||||
@@ -181,9 +181,6 @@ export const useStudioInitAction = (action?: StudioInitAction) => {
|
||||
didInit.current = true;
|
||||
|
||||
switch (action.type) {
|
||||
case 'loadWorkflow':
|
||||
handleLoadWorkflow(action.data.workflowId);
|
||||
break;
|
||||
case 'selectStylePreset':
|
||||
handleSelectStylePreset(action.data.stylePresetId);
|
||||
break;
|
||||
@@ -196,13 +193,20 @@ export const useStudioInitAction = (action?: StudioInitAction) => {
|
||||
case 'goToDestination':
|
||||
handleGoToDestination(action.data.destination);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}, [
|
||||
handleSendToCanvas,
|
||||
handleUseAllMetadata,
|
||||
action,
|
||||
handleLoadWorkflow,
|
||||
handleSelectStylePreset,
|
||||
handleGoToDestination,
|
||||
]);
|
||||
}, [handleSendToCanvas, handleUseAllMetadata, action, handleSelectStylePreset, handleGoToDestination]);
|
||||
|
||||
useEffect(() => {
|
||||
if (didInit.current || !action || !schemaLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
didInit.current = true;
|
||||
|
||||
if (action.type === 'loadWorkflow') {
|
||||
handleLoadWorkflow(action.data.workflowId);
|
||||
}
|
||||
}, [action, handleLoadWorkflow, schemaLoaded]);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user