mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
disable panels when app mounts
This commit is contained in:
@ -13,16 +13,28 @@ import { Box, Flex, Grid, Portal, useColorMode } from '@chakra-ui/react';
|
|||||||
import { APP_HEIGHT, APP_WIDTH } from 'theme/util/constants';
|
import { APP_HEIGHT, APP_WIDTH } from 'theme/util/constants';
|
||||||
import ImageGalleryPanel from 'features/gallery/components/ImageGalleryPanel';
|
import ImageGalleryPanel from 'features/gallery/components/ImageGalleryPanel';
|
||||||
import Lightbox from 'features/lightbox/components/Lightbox';
|
import Lightbox from 'features/lightbox/components/Lightbox';
|
||||||
import { useAppSelector } from './storeHooks';
|
import { useAppDispatch, useAppSelector } from './storeHooks';
|
||||||
import { PropsWithChildren, useEffect } from 'react';
|
import { PropsWithChildren, useEffect } from 'react';
|
||||||
|
import { setDisabledPanels } from 'features/ui/store/uiSlice';
|
||||||
|
|
||||||
keepGUIAlive();
|
keepGUIAlive();
|
||||||
|
|
||||||
const App = (props: PropsWithChildren) => {
|
interface Props extends PropsWithChildren {
|
||||||
|
options: {
|
||||||
|
disabledPanels: string[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const App = (props: Props) => {
|
||||||
useToastWatcher();
|
useToastWatcher();
|
||||||
|
|
||||||
const currentTheme = useAppSelector((state) => state.ui.currentTheme);
|
const currentTheme = useAppSelector((state) => state.ui.currentTheme);
|
||||||
const { setColorMode } = useColorMode();
|
const { setColorMode } = useColorMode();
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
dispatch(setDisabledPanels(props.options.disabledPanels));
|
||||||
|
}, [dispatch, props.options.disabledPanels]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setColorMode(['light'].includes(currentTheme) ? 'light' : 'dark');
|
setColorMode(['light'].includes(currentTheme) ? 'light' : 'dark');
|
||||||
|
@ -13,7 +13,7 @@ import lightboxReducer from 'features/lightbox/store/lightboxSlice';
|
|||||||
import generationReducer from 'features/parameters/store/generationSlice';
|
import generationReducer from 'features/parameters/store/generationSlice';
|
||||||
import postprocessingReducer from 'features/parameters/store/postprocessingSlice';
|
import postprocessingReducer from 'features/parameters/store/postprocessingSlice';
|
||||||
import systemReducer from 'features/system/store/systemSlice';
|
import systemReducer from 'features/system/store/systemSlice';
|
||||||
import uiReducer, { uiSlice } from 'features/ui/store/uiSlice';
|
import uiReducer from 'features/ui/store/uiSlice';
|
||||||
import apiReducer from 'services/apiSlice';
|
import apiReducer from 'services/apiSlice';
|
||||||
|
|
||||||
import { socketioMiddleware } from './socketio/middleware';
|
import { socketioMiddleware } from './socketio/middleware';
|
||||||
@ -113,41 +113,28 @@ function buildMiddleware() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InitializeStore {
|
|
||||||
disabledPanels?: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Continue with store setup
|
// Continue with store setup
|
||||||
export const initializeStore = ({ disabledPanels = [] }: InitializeStore) =>
|
export const store = configureStore({
|
||||||
configureStore({
|
reducer: persistedReducer,
|
||||||
reducer: persistedReducer,
|
middleware: (getDefaultMiddleware) =>
|
||||||
middleware: (getDefaultMiddleware) =>
|
getDefaultMiddleware({
|
||||||
getDefaultMiddleware({
|
immutableCheck: false,
|
||||||
immutableCheck: false,
|
serializableCheck: false,
|
||||||
serializableCheck: false,
|
}).concat(buildMiddleware()),
|
||||||
}).concat(buildMiddleware()),
|
devTools: {
|
||||||
preloadedState: {
|
// Uncommenting these very rapidly called actions makes the redux dev tools output much more readable
|
||||||
ui: {
|
actionsDenylist: [
|
||||||
...uiSlice.getInitialState(),
|
'canvas/setCursorPosition',
|
||||||
disabledParameterPanels: disabledPanels,
|
'canvas/setStageCoordinates',
|
||||||
},
|
'canvas/setStageScale',
|
||||||
},
|
'canvas/setIsDrawing',
|
||||||
devTools: {
|
'canvas/setBoundingBoxCoordinates',
|
||||||
// Uncommenting these very rapidly called actions makes the redux dev tools output much more readable
|
'canvas/setBoundingBoxDimensions',
|
||||||
actionsDenylist: [
|
'canvas/setIsDrawing',
|
||||||
'canvas/setCursorPosition',
|
'canvas/addPointToCurrentLine',
|
||||||
'canvas/setStageCoordinates',
|
],
|
||||||
'canvas/setStageScale',
|
},
|
||||||
'canvas/setIsDrawing',
|
});
|
||||||
'canvas/setBoundingBoxCoordinates',
|
|
||||||
'canvas/setBoundingBoxDimensions',
|
|
||||||
'canvas/setIsDrawing',
|
|
||||||
'canvas/addPointToCurrentLine',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const store = initializeStore({});
|
|
||||||
|
|
||||||
export type AppGetState = typeof store.getState;
|
export type AppGetState = typeof store.getState;
|
||||||
export type RootState = ReturnType<typeof store.getState>;
|
export type RootState = ReturnType<typeof store.getState>;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { lazy, PropsWithChildren, useEffect } from 'react';
|
import React, { lazy, PropsWithChildren, useEffect } from 'react';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { PersistGate } from 'redux-persist/integration/react';
|
import { PersistGate } from 'redux-persist/integration/react';
|
||||||
import { initializeStore } from './app/store';
|
import { store } from './app/store';
|
||||||
import { persistor } from './persistor';
|
import { persistor } from './persistor';
|
||||||
import { OpenAPI } from 'services/api';
|
import { OpenAPI } from 'services/api';
|
||||||
import '@fontsource/inter/100.css';
|
import '@fontsource/inter/100.css';
|
||||||
@ -27,18 +27,22 @@ interface Props extends PropsWithChildren {
|
|||||||
disabledPanels?: string[];
|
disabledPanels?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Component({ apiUrl, disabledPanels, children }: Props) {
|
export default function Component({
|
||||||
|
apiUrl,
|
||||||
|
disabledPanels = [],
|
||||||
|
children,
|
||||||
|
}: Props) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (apiUrl) OpenAPI.BASE = apiUrl;
|
if (apiUrl) OpenAPI.BASE = apiUrl;
|
||||||
}, [apiUrl]);
|
}, [apiUrl]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<Provider store={initializeStore({ disabledPanels })}>
|
<Provider store={store}>
|
||||||
<PersistGate loading={<Loading />} persistor={persistor}>
|
<PersistGate loading={<Loading />} persistor={persistor}>
|
||||||
<React.Suspense fallback={<Loading showText />}>
|
<React.Suspense fallback={<Loading showText />}>
|
||||||
<ThemeLocaleProvider>
|
<ThemeLocaleProvider>
|
||||||
<App>{children}</App>
|
<App options={{ disabledPanels }}>{children}</App>
|
||||||
</ThemeLocaleProvider>
|
</ThemeLocaleProvider>
|
||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
</PersistGate>
|
</PersistGate>
|
||||||
|
@ -42,7 +42,7 @@ const ParametersAccordion = (props: ParametersAccordionsType) => {
|
|||||||
accordionInfo[key];
|
accordionInfo[key];
|
||||||
|
|
||||||
// do not render if panel is disabled in global state
|
// do not render if panel is disabled in global state
|
||||||
if (disabledParameterPanels.indexOf(key) > -1) {
|
if (disabledParameterPanels.indexOf(key) === -1) {
|
||||||
accordionsToRender.push(
|
accordionsToRender.push(
|
||||||
<InvokeAccordionItem
|
<InvokeAccordionItem
|
||||||
key={key}
|
key={key}
|
||||||
|
@ -93,6 +93,9 @@ export const uiSlice = createSlice({
|
|||||||
state.shouldShowParametersPanel = true;
|
state.shouldShowParametersPanel = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
setDisabledPanels: (state, action: PayloadAction<string[]>) => {
|
||||||
|
state.disabledParameterPanels = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -114,6 +117,7 @@ export const {
|
|||||||
togglePinParametersPanel,
|
togglePinParametersPanel,
|
||||||
toggleParametersPanel,
|
toggleParametersPanel,
|
||||||
toggleGalleryPanel,
|
toggleGalleryPanel,
|
||||||
|
setDisabledPanels,
|
||||||
} = uiSlice.actions;
|
} = uiSlice.actions;
|
||||||
|
|
||||||
export default uiSlice.reducer;
|
export default uiSlice.reducer;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { initializeStore } from 'app/store';
|
import { store } from 'app/store';
|
||||||
import { persistStore } from 'redux-persist';
|
import { persistStore } from 'redux-persist';
|
||||||
|
|
||||||
export const persistor = persistStore(initializeStore({}));
|
export const persistor = persistStore(store);
|
||||||
|
Reference in New Issue
Block a user