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, useEffect } from 'react'; import { setDisabledPanels, setDisabledTabs } from 'features/ui/store/uiSlice'; import { InvokeTabName } from 'features/ui/store/tabMap'; import { shouldTransformUrlsChanged } from 'features/system/store/systemSlice'; import { setShouldFetchImages } from 'features/gallery/store/resultsSlice'; keepGUIAlive(); interface Props extends PropsWithChildren { options: { disabledPanels: string[]; disabledTabs: InvokeTabName[]; shouldTransformUrls?: boolean; shouldFetchImages: boolean; }; } const App = (props: Props) => { useToastWatcher(); const currentTheme = useAppSelector((state) => state.ui.currentTheme); const { setColorMode } = useColorMode(); const dispatch = useAppDispatch(); useEffect(() => { dispatch(setDisabledPanels(props.options.disabledPanels)); }, [dispatch, props.options.disabledPanels]); useEffect(() => { dispatch(setDisabledTabs(props.options.disabledTabs)); }, [dispatch, props.options.disabledTabs]); useEffect(() => { dispatch( shouldTransformUrlsChanged(Boolean(props.options.shouldTransformUrls)) ); }, [dispatch, props.options.shouldTransformUrls]); useEffect(() => { dispatch(setShouldFetchImages(props.options.shouldFetchImages)); }, [dispatch, props.options.shouldFetchImages]); useEffect(() => { setColorMode(['light'].includes(currentTheme) ? 'light' : 'dark'); }, [setColorMode, currentTheme]); return ( {props.children || } ); }; export default App;