tidy(ui): clean up unused code 4

variables, types and schemas
This commit is contained in:
psychedelicious 2024-02-27 17:46:13 +11:00
parent dc64089c9d
commit b661d93bd8
26 changed files with 72 additions and 217 deletions

View File

@ -4,16 +4,9 @@ const config: KnipConfig = {
ignore: [
// This file is only used during debugging
'src/app/store/middleware/debugLoggerMiddleware.ts',
// These are old schemas, used in migrations. Needs cleanup.
'src/features/nodes/types/v2/**/*',
'src/features/nodes/types/v1/**/*',
// We don't want to check the public folder - contains images and translations
'public/**/*',
],
compilers: {
//
svg: () => '',
},
ignoreDependencies: ['@storybook/addon-docs', '@storybook/blocks', '@storybook/test', 'public/.*'],
ignoreBinaries: ['only-allow'],
};
export default config;

View File

@ -3,7 +3,7 @@ import { parseify } from 'common/util/serialize';
import { PersistError, RehydrateError } from 'redux-remember';
import { serializeError } from 'serialize-error';
export type StorageErrorArgs = {
type StorageErrorArgs = {
key: string;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ // any is correct
value?: any;

View File

@ -1,4 +1,4 @@
import type { ListenerEffect, TypedStartListening, UnknownAction } from '@reduxjs/toolkit';
import type { TypedStartListening } from '@reduxjs/toolkit';
import { createListenerMiddleware } from '@reduxjs/toolkit';
import { addBulkDownloadListeners } from 'app/store/middleware/listenerMiddleware/listeners/bulkDownload';
import { addGalleryImageClickedListener } from 'app/store/middleware/listenerMiddleware/listeners/galleryImageClicked';
@ -70,12 +70,10 @@ import { addWorkflowLoadRequestedListener } from './listeners/workflowLoadReques
export const listenerMiddleware = createListenerMiddleware();
export type AppStartListening = TypedStartListening<RootState, AppDispatch>;
type AppStartListening = TypedStartListening<RootState, AppDispatch>;
export const startAppListening = listenerMiddleware.startListening as AppStartListening;
export type AppListenerEffect = ListenerEffect<UnknownAction, RootState, AppDispatch>;
/**
* The RTK listener middleware is a lightweight alternative sagas/observables.
*

View File

@ -185,7 +185,6 @@ export const createStore = (uniqueStoreKey?: string, persist = true) =>
},
});
export type AppGetState = ReturnType<ReturnType<typeof createStore>['getState']>;
export type RootState = ReturnType<ReturnType<typeof createStore>['getState']>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AppThunkDispatch = ThunkDispatch<RootState, any, UnknownAction>;

View File

@ -1,7 +1,7 @@
// https://stackoverflow.com/a/73731908
import { useCallback, useEffect, useState } from 'react';
export type UseSingleAndDoubleClickOptions = {
type UseSingleAndDoubleClickOptions = {
onSingleClick: () => void;
onDoubleClick: () => void;
latency?: number;

View File

@ -1,7 +1,5 @@
export type JSONValue = string | number | boolean | null | JSONValue[] | { [key: string]: JSONValue };
type JSONValue = string | number | boolean | null | JSONValue[] | { [key: string]: JSONValue };
export interface JSONObject {
[k: string]: JSONValue;
}
export interface JSONArray extends Array<JSONValue> {}

View File

@ -1,7 +1,7 @@
import { NUMPY_RAND_MAX, NUMPY_RAND_MIN } from 'app/constants';
import { random } from 'lodash-es';
export type GenerateSeedsArg = {
type GenerateSeedsArg = {
count: number;
start?: number;
min?: number;

View File

@ -15,7 +15,7 @@ export type BoundingBoxScaleMethod = z.infer<typeof zBoundingBoxScaleMethod>;
export const isBoundingBoxScaleMethod = (v: unknown): v is BoundingBoxScaleMethod =>
zBoundingBoxScaleMethod.safeParse(v).success;
export type CanvasDrawingTool = 'brush' | 'eraser';
type CanvasDrawingTool = 'brush' | 'eraser';
export type CanvasTool = CanvasDrawingTool | 'move' | 'colorPicker';
@ -53,7 +53,7 @@ export type CanvasBaseLine = {
clip?: IRect;
};
export type CanvasFillRect = {
type CanvasFillRect = {
kind: 'fillRect';
layer: 'base';
x: number;
@ -63,7 +63,7 @@ export type CanvasFillRect = {
color: RgbaColor;
};
export type CanvasEraseRect = {
type CanvasEraseRect = {
kind: 'eraseRect';
layer: 'base';
x: number;
@ -72,7 +72,7 @@ export type CanvasEraseRect = {
height: number;
};
export type CanvasObject = CanvasImage | CanvasBaseLine | CanvasMaskLine | CanvasFillRect | CanvasEraseRect;
type CanvasObject = CanvasImage | CanvasBaseLine | CanvasMaskLine | CanvasFillRect | CanvasEraseRect;
export type CanvasLayerState = {
objects: CanvasObject[];
@ -83,11 +83,6 @@ export type CanvasLayerState = {
};
};
export type CanvasSession = {
sessionId: string;
boundingBox: IRect;
};
// type guards
export const isCanvasMaskLine = (obj: CanvasObject): obj is CanvasMaskLine =>
obj.kind === 'line' && obj.layer === 'mask';

View File

@ -17,7 +17,7 @@ import NormalBaeProcessor from './processors/NormalBaeProcessor';
import PidiProcessor from './processors/PidiProcessor';
import ZoeDepthProcessor from './processors/ZoeDepthProcessor';
export type Props = {
type Props = {
id: string;
};

View File

@ -1,6 +1,6 @@
import type { PayloadAction } from '@reduxjs/toolkit';
import { createSlice } from '@reduxjs/toolkit';
import type { PersistConfig, RootState } from 'app/store/store';
import type { PersistConfig } from 'app/store/store';
type ModelManagerState = {
_version: 1;
@ -42,8 +42,6 @@ export const modelManagerV2Slice = createSlice({
export const { setSelectedModelKey, setSearchTerm, setFilteredModelType, setSelectedModelMode } =
modelManagerV2Slice.actions;
export const selectModelManagerSlice = (state: RootState) => state.modelmanagerV2;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
const migrateModelManagerState = (state: any): any => {
if (!('_version' in state)) {

View File

@ -3,7 +3,7 @@ import { createSlice } from '@reduxjs/toolkit';
import type { PersistConfig, RootState } from 'app/store/store';
import { z } from 'zod';
export const zParamESRGANModelName = z.enum([
const zParamESRGANModelName = z.enum([
'RealESRGAN_x4plus.pth',
'RealESRGAN_x4plus_anime_6B.pth',
'ESRGAN_SRx4_DF2KOST_official-ff704c30.pth',
@ -18,7 +18,7 @@ export interface PostprocessingState {
esrganModelName: ParamESRGANModelName;
}
export const initialPostprocessingState: PostprocessingState = {
const initialPostprocessingState: PostprocessingState = {
_version: 1,
esrganModelName: 'RealESRGAN_x4plus.pth',
};
@ -38,7 +38,7 @@ export const { esrganModelNameChanged } = postprocessingSlice.actions;
export const selectPostprocessingSlice = (state: RootState) => state.postprocessing;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export const migratePostprocessingState = (state: any): any => {
const migratePostprocessingState = (state: any): any => {
if (!('_version' in state)) {
state._version = 1;
}

View File

@ -16,68 +16,68 @@ import { z } from 'zod';
*/
// #region Positive prompt
export const zParameterPositivePrompt = z.string();
const zParameterPositivePrompt = z.string();
export type ParameterPositivePrompt = z.infer<typeof zParameterPositivePrompt>;
export const isParameterPositivePrompt = (val: unknown): val is ParameterPositivePrompt =>
zParameterPositivePrompt.safeParse(val).success;
// #endregion
// #region Negative prompt
export const zParameterNegativePrompt = z.string();
const zParameterNegativePrompt = z.string();
export type ParameterNegativePrompt = z.infer<typeof zParameterNegativePrompt>;
export const isParameterNegativePrompt = (val: unknown): val is ParameterNegativePrompt =>
zParameterNegativePrompt.safeParse(val).success;
// #endregion
// #region Positive style prompt (SDXL)
export const zParameterPositiveStylePromptSDXL = z.string();
const zParameterPositiveStylePromptSDXL = z.string();
export type ParameterPositiveStylePromptSDXL = z.infer<typeof zParameterPositiveStylePromptSDXL>;
export const isParameterPositiveStylePromptSDXL = (val: unknown): val is ParameterPositiveStylePromptSDXL =>
zParameterPositiveStylePromptSDXL.safeParse(val).success;
// #endregion
// #region Positive style prompt (SDXL)
export const zParameterNegativeStylePromptSDXL = z.string();
const zParameterNegativeStylePromptSDXL = z.string();
export type ParameterNegativeStylePromptSDXL = z.infer<typeof zParameterNegativeStylePromptSDXL>;
export const isParameterNegativeStylePromptSDXL = (val: unknown): val is ParameterNegativeStylePromptSDXL =>
zParameterNegativeStylePromptSDXL.safeParse(val).success;
// #endregion
// #region Steps
export const zParameterSteps = z.number().int().min(1);
const zParameterSteps = z.number().int().min(1);
export type ParameterSteps = z.infer<typeof zParameterSteps>;
export const isParameterSteps = (val: unknown): val is ParameterSteps => zParameterSteps.safeParse(val).success;
// #endregion
// #region CFG scale parameter
export const zParameterCFGScale = z.number().min(1);
const zParameterCFGScale = z.number().min(1);
export type ParameterCFGScale = z.infer<typeof zParameterCFGScale>;
export const isParameterCFGScale = (val: unknown): val is ParameterCFGScale =>
zParameterCFGScale.safeParse(val).success;
// #endregion
// #region CFG Rescale Multiplier
export const zParameterCFGRescaleMultiplier = z.number().gte(0).lt(1);
const zParameterCFGRescaleMultiplier = z.number().gte(0).lt(1);
export type ParameterCFGRescaleMultiplier = z.infer<typeof zParameterCFGRescaleMultiplier>;
export const isParameterCFGRescaleMultiplier = (val: unknown): val is ParameterCFGRescaleMultiplier =>
zParameterCFGRescaleMultiplier.safeParse(val).success;
// #endregion
// #region Scheduler
export const zParameterScheduler = zSchedulerField;
const zParameterScheduler = zSchedulerField;
export type ParameterScheduler = z.infer<typeof zParameterScheduler>;
export const isParameterScheduler = (val: unknown): val is ParameterScheduler =>
zParameterScheduler.safeParse(val).success;
// #endregion
// #region seed
export const zParameterSeed = z.number().int().min(0).max(NUMPY_RAND_MAX);
const zParameterSeed = z.number().int().min(0).max(NUMPY_RAND_MAX);
export type ParameterSeed = z.infer<typeof zParameterSeed>;
export const isParameterSeed = (val: unknown): val is ParameterSeed => zParameterSeed.safeParse(val).success;
// #endregion
// #region Width
export const zParameterWidth = z
const zParameterWidth = z
.number()
.min(64)
.transform((val) => roundToMultiple(val, 8));
@ -86,96 +86,81 @@ export const isParameterWidth = (val: unknown): val is ParameterWidth => zParame
// #endregion
// #region Height
export const zParameterHeight = zParameterWidth;
const zParameterHeight = zParameterWidth;
export type ParameterHeight = z.infer<typeof zParameterHeight>;
export const isParameterHeight = (val: unknown): val is ParameterHeight => zParameterHeight.safeParse(val).success;
// #endregion
// #region Aspect Ratio
export const zParameterAspectRatio = z.number().int().min(0).max(6);
const zParameterAspectRatio = z.number().int().min(0).max(6);
export type ParameterAspectRatio = z.infer<typeof zParameterAspectRatio>;
export const isParameterAspectRatio = (val: unknown): val is ParameterAspectRatio =>
zParameterAspectRatio.safeParse(val).success;
// #endregion
// #region Model
export const zParameterModel = zModelIdentifierWithBase;
export type ParameterModel = z.infer<typeof zParameterModel>;
export const isParameterModel = (val: unknown): val is ParameterModel => zParameterModel.safeParse(val).success;
// #endregion
// #region SDXL Refiner Model
export const zParameterSDXLRefinerModel = zModelIdentifierWithBase;
const zParameterSDXLRefinerModel = zModelIdentifierWithBase;
export type ParameterSDXLRefinerModel = z.infer<typeof zParameterSDXLRefinerModel>;
export const isParameterSDXLRefinerModel = (val: unknown): val is ParameterSDXLRefinerModel =>
zParameterSDXLRefinerModel.safeParse(val).success;
// #endregion
// #region VAE Model
export const zParameterVAEModel = zModelIdentifierWithBase;
export type ParameterVAEModel = z.infer<typeof zParameterVAEModel>;
export const isParameterVAEModel = (val: unknown): val is ParameterVAEModel =>
zParameterVAEModel.safeParse(val).success;
// #endregion
// #region LoRA Model
export const zParameterLoRAModel = zModelIdentifierWithBase;
const zParameterLoRAModel = zModelIdentifierWithBase;
export type ParameterLoRAModel = z.infer<typeof zParameterLoRAModel>;
export const isParameterLoRAModel = (val: unknown): val is ParameterLoRAModel =>
zParameterLoRAModel.safeParse(val).success;
// #endregion
// #region ControlNet Model
export const zParameterControlNetModel = zModelIdentifierWithBase;
export type ParameterControlNetModel = z.infer<typeof zParameterLoRAModel>;
export const isParameterControlNetModel = (val: unknown): val is ParameterControlNetModel =>
zParameterControlNetModel.safeParse(val).success;
const zParameterControlNetModel = zModelIdentifierWithBase;
export type ParameterControlNetModel = z.infer<typeof zParameterControlNetModel>;
// #endregion
// #region IP Adapter Model
export const zParameterIPAdapterModel = zModelIdentifierWithBase;
const zParameterIPAdapterModel = zModelIdentifierWithBase;
export type ParameterIPAdapterModel = z.infer<typeof zParameterIPAdapterModel>;
export const isParameterIPAdapterModel = (val: unknown): val is ParameterIPAdapterModel =>
zParameterIPAdapterModel.safeParse(val).success;
// #endregion
// #region T2I Adapter Model
export const zParameterT2IAdapterModel = zModelIdentifierWithBase;
const zParameterT2IAdapterModel = zModelIdentifierWithBase;
export type ParameterT2IAdapterModel = z.infer<typeof zParameterT2IAdapterModel>;
export const isParameterT2IAdapterModel = (val: unknown): val is ParameterT2IAdapterModel =>
zParameterT2IAdapterModel.safeParse(val).success;
// #endregion
// #region Strength (l2l strength)
export const zParameterStrength = z.number().min(0).max(1);
const zParameterStrength = z.number().min(0).max(1);
export type ParameterStrength = z.infer<typeof zParameterStrength>;
export const isParameterStrength = (val: unknown): val is ParameterStrength =>
zParameterStrength.safeParse(val).success;
// #endregion
// #region Precision
export const zParameterPrecision = z.enum(['fp16', 'fp32']);
const zParameterPrecision = z.enum(['fp16', 'fp32']);
export type ParameterPrecision = z.infer<typeof zParameterPrecision>;
export const isParameterPrecision = (val: unknown): val is ParameterPrecision =>
zParameterPrecision.safeParse(val).success;
// #endregion
// #region HRF Method
export const zParameterHRFMethod = z.enum(['ESRGAN', 'bilinear']);
const zParameterHRFMethod = z.enum(['ESRGAN', 'bilinear']);
export type ParameterHRFMethod = z.infer<typeof zParameterHRFMethod>;
export const isParameterHRFMethod = (val: unknown): val is ParameterHRFMethod =>
zParameterHRFMethod.safeParse(val).success;
// #endregion
// #region HRF Enabled
export const zParameterHRFEnabled = z.boolean();
const zParameterHRFEnabled = z.boolean();
export type ParameterHRFEnabled = z.infer<typeof zParameterHRFEnabled>;
export const isParameterHRFEnabled = (val: unknown): val is boolean =>
zParameterHRFEnabled.safeParse(val).success && val !== null && val !== undefined;
// #endregion
// #region SDXL Refiner Positive Aesthetic Score
export const zParameterSDXLRefinerPositiveAestheticScore = z.number().min(1).max(10);
const zParameterSDXLRefinerPositiveAestheticScore = z.number().min(1).max(10);
export type ParameterSDXLRefinerPositiveAestheticScore = z.infer<typeof zParameterSDXLRefinerPositiveAestheticScore>;
export const isParameterSDXLRefinerPositiveAestheticScore = (
val: unknown
@ -184,7 +169,7 @@ export const isParameterSDXLRefinerPositiveAestheticScore = (
// #endregion
// #region SDXL Refiner Negative Aesthetic Score
export const zParameterSDXLRefinerNegativeAestheticScore = zParameterSDXLRefinerPositiveAestheticScore;
const zParameterSDXLRefinerNegativeAestheticScore = zParameterSDXLRefinerPositiveAestheticScore;
export type ParameterSDXLRefinerNegativeAestheticScore = z.infer<typeof zParameterSDXLRefinerNegativeAestheticScore>;
export const isParameterSDXLRefinerNegativeAestheticScore = (
val: unknown
@ -193,28 +178,26 @@ export const isParameterSDXLRefinerNegativeAestheticScore = (
// #endregion
// #region SDXL Refiner Start
export const zParameterSDXLRefinerStart = z.number().min(0).max(1);
const zParameterSDXLRefinerStart = z.number().min(0).max(1);
export type ParameterSDXLRefinerStart = z.infer<typeof zParameterSDXLRefinerStart>;
export const isParameterSDXLRefinerStart = (val: unknown): val is ParameterSDXLRefinerStart =>
zParameterSDXLRefinerStart.safeParse(val).success;
// #endregion
// #region Mask Blur Method
export const zParameterMaskBlurMethod = z.enum(['box', 'gaussian']);
const zParameterMaskBlurMethod = z.enum(['box', 'gaussian']);
export type ParameterMaskBlurMethod = z.infer<typeof zParameterMaskBlurMethod>;
export const isParameterMaskBlurMethod = (val: unknown): val is ParameterMaskBlurMethod =>
zParameterMaskBlurMethod.safeParse(val).success;
// #endregion
// #region Canvas Coherence Mode
export const zParameterCanvasCoherenceMode = z.enum(['Gaussian Blur', 'Box Blur', 'Staged']);
const zParameterCanvasCoherenceMode = z.enum(['Gaussian Blur', 'Box Blur', 'Staged']);
export type ParameterCanvasCoherenceMode = z.infer<typeof zParameterCanvasCoherenceMode>;
export const isParameterCanvasCoherenceMode = (val: unknown): val is ParameterCanvasCoherenceMode =>
zParameterCanvasCoherenceMode.safeParse(val).success;
// #endregion
// #region LoRA weight
export const zLoRAWeight = z.number();
const zLoRAWeight = z.number();
export type ParameterLoRAWeight = z.infer<typeof zLoRAWeight>;
export const isParameterLoRAWeight = (val: unknown): val is ParameterLoRAWeight => zLoRAWeight.safeParse(val).success;
// #endregion

View File

@ -1,6 +1,5 @@
import type { PayloadAction } from '@reduxjs/toolkit';
import { createSlice } from '@reduxjs/toolkit';
import type { RootState } from 'app/store/store';
export interface QueueState {
listCursor: number | undefined;
@ -9,18 +8,16 @@ export interface QueueState {
resumeProcessorOnEnqueue: boolean;
}
export const initialQueueState: QueueState = {
const initialQueueState: QueueState = {
listCursor: undefined,
listPriority: undefined,
selectedQueueItem: undefined,
resumeProcessorOnEnqueue: true,
};
const initialState: QueueState = initialQueueState;
export const queueSlice = createSlice({
name: 'queue',
initialState,
initialState: initialQueueState,
reducers: {
listCursorChanged: (state, action: PayloadAction<number | undefined>) => {
state.listCursor = action.payload;
@ -32,25 +29,7 @@ export const queueSlice = createSlice({
state.listCursor = undefined;
state.listPriority = undefined;
},
queueItemSelectionToggled: (state, action: PayloadAction<string | undefined>) => {
if (state.selectedQueueItem === action.payload) {
state.selectedQueueItem = undefined;
} else {
state.selectedQueueItem = action.payload;
}
},
resumeProcessorOnEnqueueChanged: (state, action: PayloadAction<boolean>) => {
state.resumeProcessorOnEnqueue = action.payload;
},
},
});
export const {
listCursorChanged,
listPriorityChanged,
listParamsReset,
queueItemSelectionToggled,
resumeProcessorOnEnqueueChanged,
} = queueSlice.actions;
export const selectQueueSlice = (state: RootState) => state.queue;
export const { listCursorChanged, listPriorityChanged, listParamsReset } = queueSlice.actions;

View File

@ -22,7 +22,7 @@ type SDXLState = {
refinerStart: number;
};
export const initialSDXLState: SDXLState = {
const initialSDXLState: SDXLState = {
_version: 1,
positiveStylePrompt: '',
negativeStylePrompt: '',
@ -89,7 +89,7 @@ export const {
export const selectSdxlSlice = (state: RootState) => state.sdxl;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export const migrateSDXLState = (state: any): any => {
const migrateSDXLState = (state: any): any => {
if (!('_version' in state)) {
state._version = 1;
}

View File

@ -2,11 +2,11 @@ import { Flex, Heading } from '@invoke-ai/ui-library';
import type { PropsWithChildren } from 'react';
import { memo } from 'react';
export type StickyScrollableHeadingProps = {
type StickyScrollableHeadingProps = {
title: string;
};
export const StickyScrollableHeading = memo((props: StickyScrollableHeadingProps) => {
const StickyScrollableHeading = memo((props: StickyScrollableHeadingProps) => {
return (
<Flex ps={2} pb={4} position="sticky" zIndex={1} top={0} bg="base.800">
<Heading size="sm">{props.title}</Heading>
@ -16,9 +16,9 @@ export const StickyScrollableHeading = memo((props: StickyScrollableHeadingProps
StickyScrollableHeading.displayName = 'StickyScrollableHeading';
export type StickyScrollableContentProps = PropsWithChildren;
type StickyScrollableContentProps = PropsWithChildren;
export const StickyScrollableContent = memo((props: StickyScrollableContentProps) => {
const StickyScrollableContent = memo((props: StickyScrollableContentProps) => {
return (
<Flex p={4} borderRadius="base" bg="base.750" flexDir="column" gap={4}>
{props.children}

View File

@ -14,7 +14,7 @@ const baseDimensionConfig: NumericalParameterConfig = {
coarseStep: 64,
};
export const initialConfigState: AppConfig = {
const initialConfigState: AppConfig = {
shouldUpdateImagesOnConnect: false,
shouldFetchMetadataFromApi: false,
disabledTabs: [],

View File

@ -24,7 +24,7 @@ import {
import type { Language, SystemState } from './types';
export const initialSystemState: SystemState = {
const initialSystemState: SystemState = {
_version: 1,
isConnected: false,
shouldConfirmOnDelete: true,
@ -199,7 +199,7 @@ const isAnyServerError = isAnyOf(socketInvocationError, socketSessionRetrievalEr
export const selectSystemSlice = (state: RootState) => state.system;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export const migrateSystemState = (state: any): any => {
const migrateSystemState = (state: any): any => {
if (!('_version' in state)) {
state._version = 1;
}

View File

@ -15,7 +15,7 @@ export type DenoiseProgress = {
percentage: number;
};
export const zLanguage = z.enum([
const zLanguage = z.enum([
'ar',
'az',
'de',
@ -58,11 +58,3 @@ export interface SystemState {
status: SystemStatus;
shouldEnableInformationalPopovers: boolean;
}
export const STATUS_TRANSLATION_KEYS: Record<SystemStatus, string> = {
CONNECTED: 'common.statusConnected',
DISCONNECTED: 'common.statusDisconnected',
PROCESSING: 'common.statusProcessing',
ERROR: 'common.statusError',
LOADING_MODEL: 'common.statusLoadingModel',
};

View File

@ -85,8 +85,8 @@ const enabledTabsSelector = createMemoizedSelector(selectConfigSlice, (config) =
tabs.filter((tab) => !config.disabledTabs.includes(tab.id))
);
export const NO_GALLERY_PANEL_TABS: InvokeTabName[] = ['modelManager', 'queue'];
export const NO_OPTIONS_PANEL_TABS: InvokeTabName[] = ['modelManager', 'queue'];
const NO_GALLERY_PANEL_TABS: InvokeTabName[] = ['modelManager', 'queue'];
const NO_OPTIONS_PANEL_TABS: InvokeTabName[] = ['modelManager', 'queue'];
const panelStyles: CSSProperties = { height: '100%', width: '100%' };
const GALLERY_MIN_SIZE_PX = 310;
const GALLERY_MIN_SIZE_PCT = 20;

View File

@ -6,7 +6,7 @@ import { initialImageChanged } from 'features/parameters/store/generationSlice';
import type { InvokeTabName } from './tabMap';
import type { UIState } from './uiTypes';
export const initialUIState: UIState = {
const initialUIState: UIState = {
_version: 1,
activeTab: 'txt2img',
shouldShowImageDetails: false,
@ -60,7 +60,7 @@ export const {
export const selectUiSlice = (state: RootState) => state.ui;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export const migrateUIState = (state: any): any => {
const migrateUIState = (state: any): any => {
if (!('_version' in state)) {
state._version = 1;
}

View File

@ -1,11 +1,5 @@
import { ASSETS_CATEGORIES, IMAGE_CATEGORIES } from 'features/gallery/store/types';
import type {
BoardDTO,
ListBoardsArg,
OffsetPaginatedResults_BoardDTO_,
OffsetPaginatedResults_ImageDTO_,
UpdateBoardArg,
} from 'services/api/types';
import type { BoardDTO, OffsetPaginatedResults_ImageDTO_, UpdateBoardArg } from 'services/api/types';
import { getListImagesUrl } from 'services/api/util';
import type { ApiTagDescription } from '..';
@ -24,26 +18,6 @@ export const boardsApi = api.injectEndpoints({
/**
* Boards Queries
*/
listBoards: build.query<OffsetPaginatedResults_BoardDTO_, ListBoardsArg>({
query: (arg) => ({ url: buildBoardsUrl(), params: arg }),
providesTags: (result) => {
// any list of boards
const tags: ApiTagDescription[] = [{ type: 'Board', id: LIST_TAG }, 'FetchOnReconnect'];
if (result) {
// and individual tags for each board
tags.push(
...result.items.map(({ board_id }) => ({
type: 'Board' as const,
id: board_id,
}))
);
}
return tags;
},
}),
listAllBoards: build.query<Array<BoardDTO>, void>({
query: () => ({
url: buildBoardsUrl(),
@ -134,7 +108,6 @@ export const boardsApi = api.injectEndpoints({
});
export const {
useListBoardsQuery,
useListAllBoardsQuery,
useGetBoardImagesTotalQuery,
useGetBoardAssetsTotalQuery,

View File

@ -376,40 +376,6 @@ export const imagesApi = api.injectEndpoints({
}
},
}),
/**
* Change an image's `session_id` association.
*/
changeImageSessionId: build.mutation<ImageDTO, { imageDTO: ImageDTO; session_id: string }>({
query: ({ imageDTO, session_id }) => ({
url: buildImagesUrl(`i/${imageDTO.image_name}`),
method: 'PATCH',
body: { session_id },
}),
async onQueryStarted({ imageDTO, session_id }, { dispatch, queryFulfilled }) {
/**
* Cache changes for `changeImageSessionId`:
* - *update* getImageDTO
*/
// Store patches so we can undo if the query fails
const patches: PatchCollection[] = [];
// *update* getImageDTO
patches.push(
dispatch(
imagesApi.util.updateQueryData('getImageDTO', imageDTO.image_name, (draft) => {
Object.assign(draft, { session_id });
})
)
);
try {
await queryFulfilled;
} catch {
patches.forEach((patchResult) => patchResult.undo());
}
},
}),
/**
* Star a list of images.
*/
@ -1336,13 +1302,10 @@ export const imagesApi = api.injectEndpoints({
export const {
useGetIntermediatesCountQuery,
useListImagesQuery,
useLazyListImagesQuery,
useGetImageDTOQuery,
useGetImageMetadataQuery,
useGetImageWorkflowQuery,
useLazyGetImageWorkflowQuery,
useDeleteImageMutation,
useDeleteImagesMutation,
useUploadImageMutation,
useClearIntermediatesMutation,
useAddImagesToBoardMutation,
@ -1350,7 +1313,6 @@ export const {
useAddImageToBoardMutation,
useRemoveImageFromBoardMutation,
useChangeImageIsIntermediateMutation,
useChangeImageSessionIdMutation,
useDeleteBoardAndImagesMutation,
useDeleteBoardMutation,
useStarImagesMutation,

View File

@ -66,50 +66,45 @@ type ScanFolderArg = operations['scan_for_models']['parameters']['query'];
export type GetByAttrsArg = operations['get_model_records_by_attrs']['parameters']['query'];
export const mainModelsAdapter = createEntityAdapter<MainModelConfig, string>({
const mainModelsAdapter = createEntityAdapter<MainModelConfig, string>({
selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name),
});
export const mainModelsAdapterSelectors = mainModelsAdapter.getSelectors(undefined, getSelectorsOptions);
export const loraModelsAdapter = createEntityAdapter<LoRAModelConfig, string>({
const loraModelsAdapter = createEntityAdapter<LoRAModelConfig, string>({
selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name),
});
export const loraModelsAdapterSelectors = loraModelsAdapter.getSelectors(undefined, getSelectorsOptions);
export const controlNetModelsAdapter = createEntityAdapter<ControlNetModelConfig, string>({
const controlNetModelsAdapter = createEntityAdapter<ControlNetModelConfig, string>({
selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name),
});
export const controlNetModelsAdapterSelectors = controlNetModelsAdapter.getSelectors(undefined, getSelectorsOptions);
export const ipAdapterModelsAdapter = createEntityAdapter<IPAdapterModelConfig, string>({
const ipAdapterModelsAdapter = createEntityAdapter<IPAdapterModelConfig, string>({
selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name),
});
export const ipAdapterModelsAdapterSelectors = ipAdapterModelsAdapter.getSelectors(undefined, getSelectorsOptions);
export const t2iAdapterModelsAdapter = createEntityAdapter<T2IAdapterModelConfig, string>({
const t2iAdapterModelsAdapter = createEntityAdapter<T2IAdapterModelConfig, string>({
selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name),
});
export const t2iAdapterModelsAdapterSelectors = t2iAdapterModelsAdapter.getSelectors(undefined, getSelectorsOptions);
export const textualInversionModelsAdapter = createEntityAdapter<TextualInversionModelConfig, string>({
const textualInversionModelsAdapter = createEntityAdapter<TextualInversionModelConfig, string>({
selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name),
});
export const textualInversionModelsAdapterSelectors = textualInversionModelsAdapter.getSelectors(
undefined,
getSelectorsOptions
);
export const vaeModelsAdapter = createEntityAdapter<VAEModelConfig, string>({
const vaeModelsAdapter = createEntityAdapter<VAEModelConfig, string>({
selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name),
});
export const vaeModelsAdapterSelectors = vaeModelsAdapter.getSelectors(undefined, getSelectorsOptions);
export const anyModelConfigAdapter = createEntityAdapter<AnyModelConfig, string>({
const anyModelConfigAdapter = createEntityAdapter<AnyModelConfig, string>({
selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name),
});
export const anyModelConfigAdapterSelectors = anyModelConfigAdapter.getSelectors(undefined, getSelectorsOptions);
const anyModelConfigAdapterSelectors = anyModelConfigAdapter.getSelectors(undefined, getSelectorsOptions);
const buildProvidesTags =
<TEntity extends AnyModelConfig>(tagType: (typeof tagTypes)[number]) =>
@ -338,7 +333,6 @@ export const modelsApi = api.injectEndpoints({
});
export const {
useGetModelConfigByAttrsQuery,
useGetModelConfigQuery,
useGetMainModelsQuery,
useGetControlNetModelsQuery,
@ -352,7 +346,6 @@ export const {
useInstallModelMutation,
useConvertMainModelsMutation,
useSyncModelsMutation,
useScanModelsQuery,
useLazyScanModelsQuery,
useGetModelImportsQuery,
useGetModelMetadataQuery,

View File

@ -314,10 +314,8 @@ export const {
useResumeProcessorMutation,
useClearQueueMutation,
usePruneQueueMutation,
useGetCurrentQueueItemQuery,
useGetQueueStatusQuery,
useGetQueueItemQuery,
useGetNextQueueItemQuery,
useListQueueItemsQuery,
useCancelQueueItemMutation,
useGetBatchStatusQuery,

View File

@ -28,5 +28,3 @@ export const utilitiesApi = api.injectEndpoints({
}),
}),
});
export const { useDynamicPromptsQuery } = utilitiesApi;

View File

@ -101,10 +101,6 @@ export const isT2IAdapterModelConfig = (config: AnyModelConfig): config is T2IAd
return config.type === 't2i_adapter';
};
export const isTextualInversionModelConfig = (config: AnyModelConfig): config is TextualInversionModelConfig => {
return config.type === 'embedding';
};
export const isNonRefinerMainModelConfig = (config: AnyModelConfig): config is MainModelConfig => {
return config.type === 'main' && config.base !== 'sdxl-refiner';
};