moving shouldHidePreview from gallery to ui slice.

This commit is contained in:
SammCheese 2023-04-15 11:49:30 +02:00 committed by psychedelicious
parent 116107f464
commit d73f3adc43
6 changed files with 13 additions and 17 deletions

View File

@ -8,10 +8,7 @@ import IAIButton from 'common/components/IAIButton';
import IAIIconButton from 'common/components/IAIIconButton'; import IAIIconButton from 'common/components/IAIIconButton';
import IAIPopover from 'common/components/IAIPopover'; import IAIPopover from 'common/components/IAIPopover';
import { setInitialCanvasImage } from 'features/canvas/store/canvasSlice'; import { setInitialCanvasImage } from 'features/canvas/store/canvasSlice';
import { import { GalleryState } from 'features/gallery/store/gallerySlice';
GalleryState,
setShouldHidePreview,
} from 'features/gallery/store/gallerySlice';
import { lightboxSelector } from 'features/lightbox/store/lightboxSelectors'; import { lightboxSelector } from 'features/lightbox/store/lightboxSelectors';
import { setIsLightboxOpen } from 'features/lightbox/store/lightboxSlice'; import { setIsLightboxOpen } from 'features/lightbox/store/lightboxSlice';
import FaceRestoreSettings from 'features/parameters/components/AdvancedParameters/FaceRestore/FaceRestoreSettings'; import FaceRestoreSettings from 'features/parameters/components/AdvancedParameters/FaceRestore/FaceRestoreSettings';
@ -30,6 +27,7 @@ import {
} from 'features/ui/store/uiSelectors'; } from 'features/ui/store/uiSelectors';
import { import {
setActiveTab, setActiveTab,
setShouldHidePreview,
setShouldShowImageDetails, setShouldShowImageDetails,
} from 'features/ui/store/uiSlice'; } from 'features/ui/store/uiSlice';
import { useHotkeys } from 'react-hotkeys-hook'; import { useHotkeys } from 'react-hotkeys-hook';
@ -80,9 +78,9 @@ const currentImageButtonsSelector = createSelector(
const { isLightboxOpen } = lightbox; const { isLightboxOpen } = lightbox;
const { shouldShowImageDetails } = ui; const { shouldShowImageDetails, shouldHidePreview } = ui;
const { intermediateImage, currentImage, shouldHidePreview } = gallery; const { intermediateImage, currentImage } = gallery;
return { return {
isProcessing, isProcessing,

View File

@ -15,8 +15,8 @@ import CurrentImageHidden from './CurrentImageHidden';
export const imagesSelector = createSelector( export const imagesSelector = createSelector(
[gallerySelector, uiSelector], [gallerySelector, uiSelector],
(gallery: GalleryState, ui) => { (gallery: GalleryState, ui) => {
const { currentImage, intermediateImage, shouldHidePreview } = gallery; const { currentImage, intermediateImage } = gallery;
const { shouldShowImageDetails } = ui; const { shouldShowImageDetails, shouldHidePreview } = ui;
return { return {
imageToDisplay: intermediateImage ? intermediateImage : currentImage, imageToDisplay: intermediateImage ? intermediateImage : currentImage,

View File

@ -39,7 +39,6 @@ export interface GalleryState {
currentCategory: GalleryCategory; currentCategory: GalleryCategory;
galleryWidth: number; galleryWidth: number;
shouldUseSingleGalleryColumn: boolean; shouldUseSingleGalleryColumn: boolean;
shouldHidePreview: boolean;
} }
const initialState: GalleryState = { const initialState: GalleryState = {
@ -64,7 +63,6 @@ const initialState: GalleryState = {
}, },
galleryWidth: 300, galleryWidth: 300,
shouldUseSingleGalleryColumn: false, shouldUseSingleGalleryColumn: false,
shouldHidePreview: false,
}; };
export const gallerySlice = createSlice({ export const gallerySlice = createSlice({
@ -253,15 +251,11 @@ export const gallerySlice = createSlice({
) => { ) => {
state.shouldUseSingleGalleryColumn = action.payload; state.shouldUseSingleGalleryColumn = action.payload;
}, },
setShouldHidePreview: (state, action: PayloadAction<boolean>) => {
state.shouldHidePreview = action.payload;
},
}, },
}); });
export const { export const {
addImage, addImage,
setShouldHidePreview,
clearIntermediateImage, clearIntermediateImage,
removeImage, removeImage,
setCurrentImage, setCurrentImage,

View File

@ -11,9 +11,7 @@ export default function InitImagePreview() {
(state: RootState) => state.generation.initialImage (state: RootState) => state.generation.initialImage
); );
const { shouldHidePreview } = useAppSelector( const { shouldHidePreview } = useAppSelector((state: RootState) => state.ui);
(state: RootState) => state.gallery
);
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -16,6 +16,7 @@ const initialtabsState: UIState = {
addNewModelUIOption: null, addNewModelUIOption: null,
shouldPinGallery: true, shouldPinGallery: true,
shouldShowGallery: true, shouldShowGallery: true,
shouldHidePreview: false,
}; };
const initialState: UIState = initialtabsState; const initialState: UIState = initialtabsState;
@ -53,6 +54,9 @@ export const uiSlice = createSlice({
setShouldUseCanvasBetaLayout: (state, action: PayloadAction<boolean>) => { setShouldUseCanvasBetaLayout: (state, action: PayloadAction<boolean>) => {
state.shouldUseCanvasBetaLayout = action.payload; state.shouldUseCanvasBetaLayout = action.payload;
}, },
setShouldHidePreview: (state, action: PayloadAction<boolean>) => {
state.shouldHidePreview = action.payload;
},
setShouldShowExistingModelsInSearch: ( setShouldShowExistingModelsInSearch: (
state, state,
action: PayloadAction<boolean> action: PayloadAction<boolean>
@ -106,6 +110,7 @@ export const {
setShouldShowExistingModelsInSearch, setShouldShowExistingModelsInSearch,
setShouldUseSliders, setShouldUseSliders,
setAddNewModelUIOption, setAddNewModelUIOption,
setShouldHidePreview,
setShouldPinGallery, setShouldPinGallery,
setShouldShowGallery, setShouldShowGallery,
togglePanels, togglePanels,

View File

@ -11,6 +11,7 @@ export interface UIState {
shouldShowExistingModelsInSearch: boolean; shouldShowExistingModelsInSearch: boolean;
shouldUseSliders: boolean; shouldUseSliders: boolean;
addNewModelUIOption: AddNewModelType; addNewModelUIOption: AddNewModelType;
shouldHidePreview: boolean;
shouldPinGallery: boolean; shouldPinGallery: boolean;
shouldShowGallery: boolean; shouldShowGallery: boolean;
} }