mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add callback to signal app is ready
needed for commercial
This commit is contained in:
parent
dac82adb5b
commit
f5df150097
@ -30,9 +30,14 @@ const DEFAULT_CONFIG = {};
|
|||||||
interface Props {
|
interface Props {
|
||||||
config?: PartialAppConfig;
|
config?: PartialAppConfig;
|
||||||
headerComponent?: ReactNode;
|
headerComponent?: ReactNode;
|
||||||
|
setIsReady?: (isReady: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const App = ({ config = DEFAULT_CONFIG, headerComponent }: Props) => {
|
const App = ({
|
||||||
|
config = DEFAULT_CONFIG,
|
||||||
|
headerComponent,
|
||||||
|
setIsReady,
|
||||||
|
}: Props) => {
|
||||||
useToastWatcher();
|
useToastWatcher();
|
||||||
useGlobalHotkeys();
|
useGlobalHotkeys();
|
||||||
|
|
||||||
@ -61,6 +66,16 @@ const App = ({ config = DEFAULT_CONFIG, headerComponent }: Props) => {
|
|||||||
setLoadingOverridden(true);
|
setLoadingOverridden(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isApplicationReady && setIsReady) {
|
||||||
|
setIsReady(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
setIsReady && setIsReady(false);
|
||||||
|
};
|
||||||
|
}, [isApplicationReady, setIsReady]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid w="100vw" h="100vh" position="relative" overflow="hidden">
|
<Grid w="100vw" h="100vh" position="relative" overflow="hidden">
|
||||||
{isLightboxEnabled && <Lightbox />}
|
{isLightboxEnabled && <Lightbox />}
|
||||||
|
@ -24,9 +24,16 @@ interface Props extends PropsWithChildren {
|
|||||||
token?: string;
|
token?: string;
|
||||||
config?: PartialAppConfig;
|
config?: PartialAppConfig;
|
||||||
headerComponent?: ReactNode;
|
headerComponent?: ReactNode;
|
||||||
|
setIsReady?: (isReady: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const InvokeAIUI = ({ apiUrl, token, config, headerComponent }: Props) => {
|
const InvokeAIUI = ({
|
||||||
|
apiUrl,
|
||||||
|
token,
|
||||||
|
config,
|
||||||
|
headerComponent,
|
||||||
|
setIsReady,
|
||||||
|
}: Props) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// configure API client token
|
// configure API client token
|
||||||
if (token) {
|
if (token) {
|
||||||
@ -55,7 +62,11 @@ const InvokeAIUI = ({ apiUrl, token, config, headerComponent }: Props) => {
|
|||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<React.Suspense fallback={<Loading />}>
|
<React.Suspense fallback={<Loading />}>
|
||||||
<ThemeLocaleProvider>
|
<ThemeLocaleProvider>
|
||||||
<App config={config} headerComponent={headerComponent} />
|
<App
|
||||||
|
config={config}
|
||||||
|
headerComponent={headerComponent}
|
||||||
|
setIsReady={setIsReady}
|
||||||
|
/>
|
||||||
</ThemeLocaleProvider>
|
</ThemeLocaleProvider>
|
||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
</Provider>
|
</Provider>
|
||||||
|
Loading…
Reference in New Issue
Block a user