2022-09-18 07:33:09 +00:00
|
|
|
import { useEffect, useState } from 'react';
|
2022-09-20 13:17:31 +00:00
|
|
|
import ProgressBar from '../features/system/ProgressBar';
|
|
|
|
import SiteHeader from '../features/system/SiteHeader';
|
2022-10-03 16:15:26 +00:00
|
|
|
import Console from '../features/system/Console';
|
2022-09-18 07:33:09 +00:00
|
|
|
import Loading from '../Loading';
|
|
|
|
import { useAppDispatch } from './store';
|
2022-09-26 01:50:47 +00:00
|
|
|
import { requestSystemConfig } from './socketio/actions';
|
2022-10-03 16:15:26 +00:00
|
|
|
import { keepGUIAlive } from './utils';
|
2022-10-30 03:36:28 +00:00
|
|
|
import InvokeTabs, { tabMap } from '../features/tabs/InvokeTabs';
|
2022-10-29 12:34:21 +00:00
|
|
|
import ImageUploader from '../common/components/ImageUploader';
|
2022-10-30 03:36:28 +00:00
|
|
|
import { RootState, useAppSelector } from '../app/store';
|
|
|
|
|
|
|
|
import ShowHideGalleryButton from '../features/tabs/ShowHideGalleryButton';
|
|
|
|
import ShowHideOptionsPanelButton from '../features/tabs/ShowHideOptionsPanelButton';
|
|
|
|
import { createSelector } from '@reduxjs/toolkit';
|
|
|
|
import { GalleryState } from '../features/gallery/gallerySlice';
|
|
|
|
import { OptionsState } from '../features/options/optionsSlice';
|
2022-10-03 16:15:26 +00:00
|
|
|
|
|
|
|
keepGUIAlive();
|
2022-09-16 17:18:15 +00:00
|
|
|
|
2022-10-30 03:36:28 +00:00
|
|
|
const appSelector = createSelector(
|
|
|
|
[(state: RootState) => state.gallery, (state: RootState) => state.options],
|
|
|
|
(gallery: GalleryState, options: OptionsState) => {
|
|
|
|
const { shouldShowGallery, shouldHoldGalleryOpen, shouldPinGallery } =
|
|
|
|
gallery;
|
|
|
|
const {
|
|
|
|
shouldShowOptionsPanel,
|
|
|
|
shouldHoldOptionsPanelOpen,
|
|
|
|
shouldPinOptionsPanel,
|
|
|
|
activeTab,
|
|
|
|
} = options;
|
|
|
|
|
|
|
|
return {
|
|
|
|
shouldShowGalleryButton: !(
|
|
|
|
shouldShowGallery ||
|
|
|
|
(shouldHoldGalleryOpen && !shouldPinGallery)
|
|
|
|
),
|
|
|
|
shouldShowOptionsPanelButton:
|
|
|
|
!(
|
|
|
|
shouldShowOptionsPanel ||
|
|
|
|
(shouldHoldOptionsPanelOpen && !shouldPinOptionsPanel)
|
|
|
|
) && ['txt2img', 'img2img', 'inpainting'].includes(tabMap[activeTab]),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2022-09-16 17:18:15 +00:00
|
|
|
const App = () => {
|
2022-09-17 06:32:59 +00:00
|
|
|
const dispatch = useAppDispatch();
|
2022-10-29 12:34:21 +00:00
|
|
|
|
2022-09-18 07:33:09 +00:00
|
|
|
const [isReady, setIsReady] = useState<boolean>(false);
|
2022-09-17 06:32:59 +00:00
|
|
|
|
2022-10-30 03:36:28 +00:00
|
|
|
const { shouldShowGalleryButton, shouldShowOptionsPanelButton } =
|
|
|
|
useAppSelector(appSelector);
|
|
|
|
|
2022-09-17 06:32:59 +00:00
|
|
|
useEffect(() => {
|
2022-09-20 13:17:31 +00:00
|
|
|
dispatch(requestSystemConfig());
|
2022-09-18 07:33:09 +00:00
|
|
|
setIsReady(true);
|
2022-09-17 06:32:59 +00:00
|
|
|
}, [dispatch]);
|
|
|
|
|
2022-09-18 07:33:09 +00:00
|
|
|
return isReady ? (
|
2022-10-03 16:15:26 +00:00
|
|
|
<div className="App">
|
2022-10-29 12:34:21 +00:00
|
|
|
<ImageUploader>
|
|
|
|
<ProgressBar />
|
|
|
|
<div className="app-content">
|
|
|
|
<SiteHeader />
|
|
|
|
<InvokeTabs />
|
|
|
|
</div>
|
|
|
|
<div className="app-console">
|
|
|
|
<Console />
|
|
|
|
</div>
|
2022-10-30 03:36:28 +00:00
|
|
|
{shouldShowGalleryButton && <ShowHideGalleryButton />}
|
|
|
|
{shouldShowOptionsPanelButton && <ShowHideOptionsPanelButton />}
|
2022-10-29 12:34:21 +00:00
|
|
|
</ImageUploader>
|
2022-10-03 16:15:26 +00:00
|
|
|
</div>
|
2022-09-18 07:33:09 +00:00
|
|
|
) : (
|
|
|
|
<Loading />
|
2022-09-17 06:32:59 +00:00
|
|
|
);
|
2022-09-16 17:18:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default App;
|