diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketConnected.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketConnected.ts index cab4738373..fe4bce682b 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketConnected.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketConnected.ts @@ -1,6 +1,5 @@ import { log } from 'app/logging/useLogger'; import { appSocketConnected, socketConnected } from 'services/events/actions'; -import { receivedPageOfImages } from 'services/api/thunks/image'; import { receivedOpenAPISchema } from 'services/api/thunks/schema'; import { startAppListening } from '../..'; @@ -14,19 +13,10 @@ export const addSocketConnectedEventListener = () => { moduleLog.debug({ timestamp }, 'Connected'); - const { nodes, config, gallery } = getState(); + const { nodes, config } = getState(); const { disabledTabs } = config; - if (!gallery.ids.length) { - dispatch( - receivedPageOfImages({ - categories: ['general'], - is_intermediate: false, - }) - ); - } - if (!nodes.schema && !disabledTabs.includes('nodes')) { dispatch(receivedOpenAPISchema()); } diff --git a/invokeai/frontend/web/src/common/hooks/useIsReadyToInvoke.ts b/invokeai/frontend/web/src/common/hooks/useIsReadyToInvoke.ts index c75041eb6c..605aa8b162 100644 --- a/invokeai/frontend/web/src/common/hooks/useIsReadyToInvoke.ts +++ b/invokeai/frontend/web/src/common/hooks/useIsReadyToInvoke.ts @@ -6,10 +6,15 @@ import { validateSeedWeights } from 'common/util/seedWeightPairs'; import { generationSelector } from 'features/parameters/store/generationSelectors'; import { systemSelector } from 'features/system/store/systemSelectors'; import { activeTabNameSelector } from 'features/ui/store/uiSelectors'; +import { + modelsApi, + useGetMainModelsQuery, +} from '../../services/api/endpoints/models'; const readinessSelector = createSelector( [stateSelector, activeTabNameSelector], - ({ generation, system, batch }, activeTabName) => { + (state, activeTabName) => { + const { generation, system, batch } = state; const { shouldGenerateVariations, seedWeights, initialImage, seed } = generation; @@ -32,6 +37,13 @@ const readinessSelector = createSelector( reasonsWhyNotReady.push('No initial image selected'); } + const { isSuccess: mainModelsSuccessfullyLoaded } = + modelsApi.endpoints.getMainModels.select()(state); + if (!mainModelsSuccessfullyLoaded) { + isReady = false; + reasonsWhyNotReady.push('Models are not loaded'); + } + // TODO: job queue // Cannot generate if already processing an image if (isProcessing) { diff --git a/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx b/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx index 33edb303e3..a5fc653913 100644 --- a/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx @@ -182,6 +182,15 @@ const ImageGalleryContent = () => { return () => osInstance()?.destroy(); }, [scroller, initialize, osInstance]); + useEffect(() => { + dispatch( + receivedPageOfImages({ + categories: ['general'], + is_intermediate: false, + }) + ); + }, [dispatch]); + const handleClickImagesCategory = useCallback(() => { dispatch(imageCategoriesChanged(IMAGE_CATEGORIES)); dispatch(setGalleryView('images'));