import ImageUploader from 'common/components/ImageUploader'; import Console from 'features/system/components/Console'; import ProgressBar from 'features/system/components/ProgressBar'; import SiteHeader from 'features/system/components/SiteHeader'; import InvokeTabs from 'features/ui/components/InvokeTabs'; import { keepGUIAlive } from './utils'; import useToastWatcher from 'features/system/hooks/useToastWatcher'; import FloatingGalleryButton from 'features/ui/components/FloatingGalleryButton'; import FloatingParametersPanelButtons from 'features/ui/components/FloatingParametersPanelButtons'; import { Box, Flex, Grid, Portal, useColorMode } from '@chakra-ui/react'; import { APP_HEIGHT, APP_WIDTH } from 'theme/util/constants'; import ImageGalleryPanel from 'features/gallery/components/ImageGalleryPanel'; import Lightbox from 'features/lightbox/components/Lightbox'; import { useAppDispatch, useAppSelector } from './storeHooks'; import { PropsWithChildren, useCallback, useEffect, useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import Loading from 'common/components/Loading/Loading'; import { useIsApplicationReady } from 'features/system/hooks/useIsApplicationReady'; import { AppConfig } from './invokeai'; import { useGlobalHotkeys } from 'common/hooks/useGlobalHotkeys'; import { configChanged } from 'features/system/store/configSlice'; import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus'; keepGUIAlive(); interface Props extends PropsWithChildren { config?: Partial; } const App = ({ config = {}, children }: Props) => { useToastWatcher(); useGlobalHotkeys(); const currentTheme = useAppSelector((state) => state.ui.currentTheme); const isLightboxEnabled = useFeatureStatus('lightbox').isFeatureEnabled; const isApplicationReady = useIsApplicationReady(); const [loadingOverridden, setLoadingOverridden] = useState(false); const { setColorMode } = useColorMode(); const dispatch = useAppDispatch(); useEffect(() => { console.log('Received config: ', config); dispatch(configChanged(config)); }, [dispatch, config]); useEffect(() => { setColorMode(['light'].includes(currentTheme) ? 'light' : 'dark'); }, [setColorMode, currentTheme]); const handleOverrideClicked = useCallback(() => { setLoadingOverridden(true); }, []); return ( {isLightboxEnabled && } {children || } {!isApplicationReady && !loadingOverridden && ( )} ); }; export default App;