mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
dont render app until API is ready
This commit is contained in:
@ -7,6 +7,7 @@ import React, {
|
|||||||
PropsWithChildren,
|
PropsWithChildren,
|
||||||
ReactNode,
|
ReactNode,
|
||||||
useEffect,
|
useEffect,
|
||||||
|
useState,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { addMiddleware, resetMiddlewares } from 'redux-dynamic-middlewares';
|
import { addMiddleware, resetMiddlewares } from 'redux-dynamic-middlewares';
|
||||||
@ -36,20 +37,19 @@ const InvokeAIUI = ({
|
|||||||
middleware,
|
middleware,
|
||||||
projectId,
|
projectId,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
|
const [isReady, setIsReady] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// configure API client token
|
if (token && apiUrl && projectId) {
|
||||||
if (token) {
|
|
||||||
$authToken.set(token);
|
$authToken.set(token);
|
||||||
}
|
|
||||||
|
|
||||||
// configure API client base url
|
|
||||||
if (apiUrl) {
|
|
||||||
$baseUrl.set(apiUrl);
|
$baseUrl.set(apiUrl);
|
||||||
}
|
|
||||||
|
|
||||||
// configure API client project header
|
|
||||||
if (projectId) {
|
|
||||||
$projectId.set(projectId);
|
$projectId.set(projectId);
|
||||||
|
setIsReady(true);
|
||||||
|
} else if (token && apiUrl) {
|
||||||
|
$authToken.set(token);
|
||||||
|
$baseUrl.set(apiUrl);
|
||||||
|
setIsReady(true);
|
||||||
|
} else {
|
||||||
|
setIsReady(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset dynamically added middlewares
|
// reset dynamically added middlewares
|
||||||
@ -81,7 +81,9 @@ const InvokeAIUI = ({
|
|||||||
<React.Suspense fallback={<Loading />}>
|
<React.Suspense fallback={<Loading />}>
|
||||||
<ThemeLocaleProvider>
|
<ThemeLocaleProvider>
|
||||||
<AppDndContext>
|
<AppDndContext>
|
||||||
|
{isReady && (
|
||||||
<App config={config} headerComponent={headerComponent} />
|
<App config={config} headerComponent={headerComponent} />
|
||||||
|
)}
|
||||||
</AppDndContext>
|
</AppDndContext>
|
||||||
</ThemeLocaleProvider>
|
</ThemeLocaleProvider>
|
||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
|
Reference in New Issue
Block a user