Skip to content

Commit

Permalink
tidy(ui): organise postprocessing listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
psychedelicious committed Jul 23, 2024
1 parent 005a646 commit f9397c9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -142,7 +142,7 @@ addModelsLoadedListener(startAppListening);
addAppConfigReceivedListener(startAppListening);

// Ad-hoc upscale workflwo
addUpscaleRequestedListener(startAppListening);
addAdHocPostProcessingRequestedListener(startAppListening);

// Prompts
addDynamicPromptsListener(startAppListening);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -22,7 +22,7 @@ export const addUpscaleRequestedListener = (startAppListening: AppStartListening
const enqueueBatchArg: BatchConfig = {
prepend: true,
batch: {
graph: await buildAdHocUpscaleGraph({
graph: await buildAdHocPostProcessingGraph({
image: imageDTO,
state,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -97,7 +97,7 @@ const CurrentImageButtons = () => {
if (!imageDTO) {
return;
}
dispatch(upscaleRequested({ imageDTO }));
dispatch(adHocPostProcessingRequested({ imageDTO }));
}, [dispatch, imageDTO]);

const handleDelete = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -35,7 +35,7 @@ export const PostProcessingPopover = memo((props: Props) => {
if (!imageDTO) {
return;
}
dispatch(upscaleRequested({ imageDTO }));
dispatch(adHocPostProcessingRequested({ imageDTO }));
}, [dispatch, imageDTO, onClose]);

return (
Expand Down

0 comments on commit f9397c9

Please sign in to comment.