mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
chore(ui): clean up uiSlice
This commit is contained in:
parent
9a3727d3ad
commit
b7b5bd1b46
@ -21,11 +21,7 @@ import UnifiedCanvasParameters from './tabs/UnifiedCanvas/UnifiedCanvasParameter
|
||||
const selector = createSelector(
|
||||
[uiSelector, activeTabNameSelector, lightboxSelector],
|
||||
(ui, activeTabName, lightbox) => {
|
||||
const {
|
||||
shouldPinParametersPanel,
|
||||
shouldShowParametersPanel,
|
||||
shouldShowImageParameters,
|
||||
} = ui;
|
||||
const { shouldPinParametersPanel, shouldShowParametersPanel } = ui;
|
||||
|
||||
const { isLightboxOpen } = lightbox;
|
||||
|
||||
@ -33,7 +29,6 @@ const selector = createSelector(
|
||||
activeTabName,
|
||||
shouldPinParametersPanel,
|
||||
shouldShowParametersPanel,
|
||||
shouldShowImageParameters,
|
||||
};
|
||||
},
|
||||
defaultSelectorOptions
|
||||
|
@ -3,6 +3,4 @@ import { UIState } from './uiTypes';
|
||||
/**
|
||||
* UI slice persist denylist
|
||||
*/
|
||||
export const uiPersistDenylist: (keyof UIState)[] = [
|
||||
'floatingProgressImageRect',
|
||||
];
|
||||
export const uiPersistDenylist: (keyof UIState)[] = [];
|
||||
|
@ -1,16 +1,14 @@
|
||||
import type { PayloadAction } from '@reduxjs/toolkit';
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import { setActiveTabReducer } from './extraReducers';
|
||||
import { InvokeTabName, tabMap } from './tabMap';
|
||||
import { AddNewModelType, Coordinates, Rect, UIState } from './uiTypes';
|
||||
import { initialImageSelected } from 'features/parameters/store/actions';
|
||||
import { InvokeTabName } from './tabMap';
|
||||
import { AddNewModelType, UIState } from './uiTypes';
|
||||
import { initialImageChanged } from 'features/parameters/store/generationSlice';
|
||||
import { SCHEDULERS } from 'app/constants';
|
||||
|
||||
export const initialUIState: UIState = {
|
||||
activeTab: 0,
|
||||
currentTheme: 'dark',
|
||||
parametersPanelScrollPosition: 0,
|
||||
shouldPinParametersPanel: true,
|
||||
shouldShowParametersPanel: true,
|
||||
shouldShowImageDetails: false,
|
||||
@ -21,13 +19,7 @@ export const initialUIState: UIState = {
|
||||
shouldPinGallery: true,
|
||||
shouldShowGallery: true,
|
||||
shouldHidePreview: false,
|
||||
textTabAccordionState: [],
|
||||
imageTabAccordionState: [],
|
||||
canvasTabAccordionState: [],
|
||||
floatingProgressImageRect: { x: 0, y: 0, width: 0, height: 0 },
|
||||
shouldShowProgressImages: false,
|
||||
shouldShowProgressInViewer: false,
|
||||
shouldShowImageParameters: false,
|
||||
schedulers: SCHEDULERS,
|
||||
};
|
||||
|
||||
@ -41,12 +33,6 @@ export const uiSlice = createSlice({
|
||||
setCurrentTheme: (state, action: PayloadAction<string>) => {
|
||||
state.currentTheme = action.payload;
|
||||
},
|
||||
setParametersPanelScrollPosition: (
|
||||
state,
|
||||
action: PayloadAction<number>
|
||||
) => {
|
||||
state.parametersPanelScrollPosition = action.payload;
|
||||
},
|
||||
setShouldPinParametersPanel: (state, action: PayloadAction<boolean>) => {
|
||||
state.shouldPinParametersPanel = action.payload;
|
||||
state.shouldShowParametersPanel = true;
|
||||
@ -75,9 +61,6 @@ export const uiSlice = createSlice({
|
||||
setAddNewModelUIOption: (state, action: PayloadAction<AddNewModelType>) => {
|
||||
state.addNewModelUIOption = action.payload;
|
||||
},
|
||||
setShouldPinGallery: (state, action: PayloadAction<boolean>) => {
|
||||
state.shouldPinGallery = action.payload;
|
||||
},
|
||||
setShouldShowGallery: (state, action: PayloadAction<boolean>) => {
|
||||
state.shouldShowGallery = action.payload;
|
||||
},
|
||||
@ -108,46 +91,9 @@ export const uiSlice = createSlice({
|
||||
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>) => {
|
||||
state.shouldShowProgressInViewer = action.payload;
|
||||
},
|
||||
shouldShowImageParametersChanged: (
|
||||
state,
|
||||
action: PayloadAction<boolean>
|
||||
) => {
|
||||
state.shouldShowImageParameters = action.payload;
|
||||
},
|
||||
setSchedulers: (state, action: PayloadAction<string[]>) => {
|
||||
state.schedulers = [];
|
||||
state.schedulers = action.payload;
|
||||
@ -163,7 +109,6 @@ export const uiSlice = createSlice({
|
||||
export const {
|
||||
setActiveTab,
|
||||
setCurrentTheme,
|
||||
setParametersPanelScrollPosition,
|
||||
setShouldPinParametersPanel,
|
||||
setShouldShowParametersPanel,
|
||||
setShouldShowImageDetails,
|
||||
@ -172,19 +117,13 @@ export const {
|
||||
setShouldUseSliders,
|
||||
setAddNewModelUIOption,
|
||||
setShouldHidePreview,
|
||||
setShouldPinGallery,
|
||||
setShouldShowGallery,
|
||||
togglePanels,
|
||||
togglePinGalleryPanel,
|
||||
togglePinParametersPanel,
|
||||
toggleParametersPanel,
|
||||
toggleGalleryPanel,
|
||||
openAccordionItemsChanged,
|
||||
floatingProgressImageMoved,
|
||||
floatingProgressImageResized,
|
||||
setShouldShowProgressImages,
|
||||
setShouldShowProgressInViewer,
|
||||
shouldShowImageParametersChanged,
|
||||
setSchedulers,
|
||||
} = uiSlice.actions;
|
||||
|
||||
|
@ -15,7 +15,6 @@ export type Rect = Coordinates & Dimensions;
|
||||
export interface UIState {
|
||||
activeTab: number;
|
||||
currentTheme: string;
|
||||
parametersPanelScrollPosition: number;
|
||||
shouldPinParametersPanel: boolean;
|
||||
shouldShowParametersPanel: boolean;
|
||||
shouldShowImageDetails: boolean;
|
||||
@ -26,12 +25,6 @@ export interface UIState {
|
||||
shouldHidePreview: boolean;
|
||||
shouldPinGallery: boolean;
|
||||
shouldShowGallery: boolean;
|
||||
textTabAccordionState: number[];
|
||||
imageTabAccordionState: number[];
|
||||
canvasTabAccordionState: number[];
|
||||
floatingProgressImageRect: Rect;
|
||||
shouldShowProgressImages: boolean;
|
||||
shouldShowProgressInViewer: boolean;
|
||||
shouldShowImageParameters: boolean;
|
||||
schedulers: string[];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user