chore(ui): clean up uiSlice

This commit is contained in:
psychedelicious 2023-05-16 09:57:19 +10:00
parent 9a3727d3ad
commit b7b5bd1b46
4 changed files with 4 additions and 79 deletions

View File

@ -21,11 +21,7 @@ import UnifiedCanvasParameters from './tabs/UnifiedCanvas/UnifiedCanvasParameter
const selector = createSelector( const selector = createSelector(
[uiSelector, activeTabNameSelector, lightboxSelector], [uiSelector, activeTabNameSelector, lightboxSelector],
(ui, activeTabName, lightbox) => { (ui, activeTabName, lightbox) => {
const { const { shouldPinParametersPanel, shouldShowParametersPanel } = ui;
shouldPinParametersPanel,
shouldShowParametersPanel,
shouldShowImageParameters,
} = ui;
const { isLightboxOpen } = lightbox; const { isLightboxOpen } = lightbox;
@ -33,7 +29,6 @@ const selector = createSelector(
activeTabName, activeTabName,
shouldPinParametersPanel, shouldPinParametersPanel,
shouldShowParametersPanel, shouldShowParametersPanel,
shouldShowImageParameters,
}; };
}, },
defaultSelectorOptions defaultSelectorOptions

View File

@ -3,6 +3,4 @@ import { UIState } from './uiTypes';
/** /**
* UI slice persist denylist * UI slice persist denylist
*/ */
export const uiPersistDenylist: (keyof UIState)[] = [ export const uiPersistDenylist: (keyof UIState)[] = [];
'floatingProgressImageRect',
];

View File

@ -1,16 +1,14 @@
import type { PayloadAction } from '@reduxjs/toolkit'; import type { PayloadAction } from '@reduxjs/toolkit';
import { createSlice } from '@reduxjs/toolkit'; import { createSlice } from '@reduxjs/toolkit';
import { setActiveTabReducer } from './extraReducers'; import { setActiveTabReducer } from './extraReducers';
import { InvokeTabName, tabMap } from './tabMap'; import { InvokeTabName } from './tabMap';
import { AddNewModelType, Coordinates, Rect, UIState } from './uiTypes'; import { AddNewModelType, UIState } from './uiTypes';
import { initialImageSelected } from 'features/parameters/store/actions';
import { initialImageChanged } from 'features/parameters/store/generationSlice'; import { initialImageChanged } from 'features/parameters/store/generationSlice';
import { SCHEDULERS } from 'app/constants'; import { SCHEDULERS } from 'app/constants';
export const initialUIState: UIState = { export const initialUIState: UIState = {
activeTab: 0, activeTab: 0,
currentTheme: 'dark', currentTheme: 'dark',
parametersPanelScrollPosition: 0,
shouldPinParametersPanel: true, shouldPinParametersPanel: true,
shouldShowParametersPanel: true, shouldShowParametersPanel: true,
shouldShowImageDetails: false, shouldShowImageDetails: false,
@ -21,13 +19,7 @@ export const initialUIState: UIState = {
shouldPinGallery: true, shouldPinGallery: true,
shouldShowGallery: true, shouldShowGallery: true,
shouldHidePreview: false, shouldHidePreview: false,
textTabAccordionState: [],
imageTabAccordionState: [],
canvasTabAccordionState: [],
floatingProgressImageRect: { x: 0, y: 0, width: 0, height: 0 },
shouldShowProgressImages: false,
shouldShowProgressInViewer: false, shouldShowProgressInViewer: false,
shouldShowImageParameters: false,
schedulers: SCHEDULERS, schedulers: SCHEDULERS,
}; };
@ -41,12 +33,6 @@ export const uiSlice = createSlice({
setCurrentTheme: (state, action: PayloadAction<string>) => { setCurrentTheme: (state, action: PayloadAction<string>) => {
state.currentTheme = action.payload; state.currentTheme = action.payload;
}, },
setParametersPanelScrollPosition: (
state,
action: PayloadAction<number>
) => {
state.parametersPanelScrollPosition = action.payload;
},
setShouldPinParametersPanel: (state, action: PayloadAction<boolean>) => { setShouldPinParametersPanel: (state, action: PayloadAction<boolean>) => {
state.shouldPinParametersPanel = action.payload; state.shouldPinParametersPanel = action.payload;
state.shouldShowParametersPanel = true; state.shouldShowParametersPanel = true;
@ -75,9 +61,6 @@ export const uiSlice = createSlice({
setAddNewModelUIOption: (state, action: PayloadAction<AddNewModelType>) => { setAddNewModelUIOption: (state, action: PayloadAction<AddNewModelType>) => {
state.addNewModelUIOption = action.payload; state.addNewModelUIOption = action.payload;
}, },
setShouldPinGallery: (state, action: PayloadAction<boolean>) => {
state.shouldPinGallery = action.payload;
},
setShouldShowGallery: (state, action: PayloadAction<boolean>) => { setShouldShowGallery: (state, action: PayloadAction<boolean>) => {
state.shouldShowGallery = action.payload; state.shouldShowGallery = action.payload;
}, },
@ -108,46 +91,9 @@ export const uiSlice = createSlice({
state.shouldShowParametersPanel = true; state.shouldShowParametersPanel = true;
} }
}, },
openAccordionItemsChanged: (state, action: PayloadAction<number[]>) => {
if (tabMap[state.activeTab] === 'txt2img') {
state.textTabAccordionState = action.payload;
}
if (tabMap[state.activeTab] === 'img2img') {
state.imageTabAccordionState = action.payload;
}
if (tabMap[state.activeTab] === 'unifiedCanvas') {
state.canvasTabAccordionState = action.payload;
}
},
floatingProgressImageMoved: (state, action: PayloadAction<Coordinates>) => {
state.floatingProgressImageRect = {
...state.floatingProgressImageRect,
...action.payload,
};
},
floatingProgressImageResized: (
state,
action: PayloadAction<Partial<Rect>>
) => {
state.floatingProgressImageRect = {
...state.floatingProgressImageRect,
...action.payload,
};
},
setShouldShowProgressImages: (state, action: PayloadAction<boolean>) => {
state.shouldShowProgressImages = action.payload;
},
setShouldShowProgressInViewer: (state, action: PayloadAction<boolean>) => { setShouldShowProgressInViewer: (state, action: PayloadAction<boolean>) => {
state.shouldShowProgressInViewer = action.payload; state.shouldShowProgressInViewer = action.payload;
}, },
shouldShowImageParametersChanged: (
state,
action: PayloadAction<boolean>
) => {
state.shouldShowImageParameters = action.payload;
},
setSchedulers: (state, action: PayloadAction<string[]>) => { setSchedulers: (state, action: PayloadAction<string[]>) => {
state.schedulers = []; state.schedulers = [];
state.schedulers = action.payload; state.schedulers = action.payload;
@ -163,7 +109,6 @@ export const uiSlice = createSlice({
export const { export const {
setActiveTab, setActiveTab,
setCurrentTheme, setCurrentTheme,
setParametersPanelScrollPosition,
setShouldPinParametersPanel, setShouldPinParametersPanel,
setShouldShowParametersPanel, setShouldShowParametersPanel,
setShouldShowImageDetails, setShouldShowImageDetails,
@ -172,19 +117,13 @@ export const {
setShouldUseSliders, setShouldUseSliders,
setAddNewModelUIOption, setAddNewModelUIOption,
setShouldHidePreview, setShouldHidePreview,
setShouldPinGallery,
setShouldShowGallery, setShouldShowGallery,
togglePanels, togglePanels,
togglePinGalleryPanel, togglePinGalleryPanel,
togglePinParametersPanel, togglePinParametersPanel,
toggleParametersPanel, toggleParametersPanel,
toggleGalleryPanel, toggleGalleryPanel,
openAccordionItemsChanged,
floatingProgressImageMoved,
floatingProgressImageResized,
setShouldShowProgressImages,
setShouldShowProgressInViewer, setShouldShowProgressInViewer,
shouldShowImageParametersChanged,
setSchedulers, setSchedulers,
} = uiSlice.actions; } = uiSlice.actions;

View File

@ -15,7 +15,6 @@ export type Rect = Coordinates & Dimensions;
export interface UIState { export interface UIState {
activeTab: number; activeTab: number;
currentTheme: string; currentTheme: string;
parametersPanelScrollPosition: number;
shouldPinParametersPanel: boolean; shouldPinParametersPanel: boolean;
shouldShowParametersPanel: boolean; shouldShowParametersPanel: boolean;
shouldShowImageDetails: boolean; shouldShowImageDetails: boolean;
@ -26,12 +25,6 @@ export interface UIState {
shouldHidePreview: boolean; shouldHidePreview: boolean;
shouldPinGallery: boolean; shouldPinGallery: boolean;
shouldShowGallery: boolean; shouldShowGallery: boolean;
textTabAccordionState: number[];
imageTabAccordionState: number[];
canvasTabAccordionState: number[];
floatingProgressImageRect: Rect;
shouldShowProgressImages: boolean;
shouldShowProgressInViewer: boolean; shouldShowProgressInViewer: boolean;
shouldShowImageParameters: boolean;
schedulers: string[]; schedulers: string[];
} }