tidy(ui): organise postprocessing listeners

This commit is contained in:
psychedelicious 2024-07-24 07:42:06 +10:00
parent 5f4ce6fda3
commit b99a53e64e
5 changed files with 14 additions and 14 deletions

View File

@ -1,5 +1,6 @@
import type { TypedStartListening } from '@reduxjs/toolkit';
import { createListenerMiddleware } from '@reduxjs/toolkit';
import { addAdHocPostProcessingRequestedListener } from 'app/store/middleware/listenerMiddleware/listeners/addAdHocPostProcessingRequestedListener';
import { addCommitStagingAreaImageListener } from 'app/store/middleware/listenerMiddleware/listeners/addCommitStagingAreaImageListener';
import { addAnyEnqueuedListener } from 'app/store/middleware/listenerMiddleware/listeners/anyEnqueued';
import { addAppConfigReceivedListener } from 'app/store/middleware/listenerMiddleware/listeners/appConfigReceived';
@ -47,7 +48,6 @@ import { addModelLoadEventListener } from 'app/store/middleware/listenerMiddlewa
import { addSocketQueueItemStatusChangedEventListener } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketQueueItemStatusChanged';
import { addStagingAreaImageSavedListener } from 'app/store/middleware/listenerMiddleware/listeners/stagingAreaImageSaved';
import { addUpdateAllNodesRequestedListener } from 'app/store/middleware/listenerMiddleware/listeners/updateAllNodesRequested';
import { addUpscaleRequestedListener } from 'app/store/middleware/listenerMiddleware/listeners/upscaleRequested';
import { addWorkflowLoadRequestedListener } from 'app/store/middleware/listenerMiddleware/listeners/workflowLoadRequested';
import type { AppDispatch, RootState } from 'app/store/store';
@ -142,7 +142,7 @@ addModelsLoadedListener(startAppListening);
addAppConfigReceivedListener(startAppListening);
// Ad-hoc upscale workflwo
addUpscaleRequestedListener(startAppListening);
addAdHocPostProcessingRequestedListener(startAppListening);
// Prompts
addDynamicPromptsListener(startAppListening);

View File

@ -2,17 +2,17 @@ import { createAction } from '@reduxjs/toolkit';
import { logger } from 'app/logging/logger';
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
import { parseify } from 'common/util/serialize';
import { buildAdHocUpscaleGraph } from 'features/nodes/util/graph/buildAdHocUpscaleGraph';
import { buildAdHocPostProcessingGraph } from 'features/nodes/util/graph/buildAdHocPostProcessingGraph';
import { toast } from 'features/toast/toast';
import { t } from 'i18next';
import { queueApi } from 'services/api/endpoints/queue';
import type { BatchConfig, ImageDTO } from 'services/api/types';
export const upscaleRequested = createAction<{ imageDTO: ImageDTO }>(`upscale/upscaleRequested`);
export const adHocPostProcessingRequested = createAction<{ imageDTO: ImageDTO }>(`upscaling/postProcessingRequested`);
export const addUpscaleRequestedListener = (startAppListening: AppStartListening) => {
export const addAdHocPostProcessingRequestedListener = (startAppListening: AppStartListening) => {
startAppListening({
actionCreator: upscaleRequested,
actionCreator: adHocPostProcessingRequested,
effect: async (action, { dispatch, getState }) => {
const log = logger('session');
@ -22,7 +22,7 @@ export const addUpscaleRequestedListener = (startAppListening: AppStartListening
const enqueueBatchArg: BatchConfig = {
prepend: true,
batch: {
graph: await buildAdHocUpscaleGraph({
graph: await buildAdHocPostProcessingGraph({
image: imageDTO,
state,
}),

View File

@ -2,7 +2,7 @@ import { ButtonGroup, IconButton, Menu, MenuButton, MenuList } from '@invoke-ai/
import { useStore } from '@nanostores/react';
import { createSelector } from '@reduxjs/toolkit';
import { skipToken } from '@reduxjs/toolkit/query';
import { upscaleRequested } from 'app/store/middleware/listenerMiddleware/listeners/upscaleRequested';
import { adHocPostProcessingRequested } from 'app/store/middleware/listenerMiddleware/listeners/addAdHocPostProcessingRequestedListener';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { iiLayerAdded } from 'features/controlLayers/store/controlLayersSlice';
import { DeleteImageButton } from 'features/deleteImageModal/components/DeleteImageButton';
@ -97,7 +97,7 @@ const CurrentImageButtons = () => {
if (!imageDTO) {
return;
}
dispatch(upscaleRequested({ imageDTO }));
dispatch(adHocPostProcessingRequested({ imageDTO }));
}, [dispatch, imageDTO]);
const handleDelete = useCallback(() => {

View File

@ -15,12 +15,12 @@ type Arg = {
state: RootState;
};
export const buildAdHocUpscaleGraph = async ({ image, state }: Arg): Promise<GraphType> => {
export const buildAdHocPostProcessingGraph = async ({ image, state }: Arg): Promise<GraphType> => {
const { postProcessingModel } = state.upscale;
assert(postProcessingModel, 'No upscale model found in state');
assert(postProcessingModel, 'No post-processing model found in state');
const g = new Graph('adhoc-upscale-graph');
const g = new Graph('adhoc-post-processing-graph');
g.addNode({
id: SPANDREL,
type: 'spandrel_image_to_image',

View File

@ -9,7 +9,7 @@ import {
Text,
useDisclosure,
} from '@invoke-ai/ui-library';
import { upscaleRequested } from 'app/store/middleware/listenerMiddleware/listeners/upscaleRequested';
import { adHocPostProcessingRequested } from 'app/store/middleware/listenerMiddleware/listeners/addAdHocPostProcessingRequestedListener';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { $installModelsTab } from 'features/modelManagerV2/subpanels/InstallModels';
import ParamPostProcessingModel from 'features/parameters/components/PostProcessing/ParamPostProcessingModel';
@ -35,7 +35,7 @@ export const PostProcessingPopover = memo((props: Props) => {
if (!imageDTO) {
return;
}
dispatch(upscaleRequested({ imageDTO }));
dispatch(adHocPostProcessingRequested({ imageDTO }));
}, [dispatch, imageDTO, onClose]);
return (