mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
add boardToAddTo state so that result can be added to board when generation is complete
This commit is contained in:
parent
4defb92105
commit
7a2d3f628a
@ -9,6 +9,7 @@ import { imageMetadataReceived } from 'services/thunks/image';
|
||||
import { sessionCanceled } from 'services/thunks/session';
|
||||
import { isImageOutput } from 'services/types/guards';
|
||||
import { progressImageSet } from 'features/system/store/systemSlice';
|
||||
import { imageAddedToBoard } from '../../../../../../services/thunks/board';
|
||||
|
||||
const moduleLog = log.child({ namespace: 'socketio' });
|
||||
const nodeDenylist = ['dataURL_image'];
|
||||
@ -24,7 +25,8 @@ export const addInvocationCompleteEventListener = () => {
|
||||
|
||||
const sessionId = action.payload.data.graph_execution_state_id;
|
||||
|
||||
const { cancelType, isCancelScheduled } = getState().system;
|
||||
const { cancelType, isCancelScheduled, boardIdToAddTo } =
|
||||
getState().system;
|
||||
|
||||
// Handle scheduled cancelation
|
||||
if (cancelType === 'scheduled' && isCancelScheduled) {
|
||||
@ -38,6 +40,17 @@ export const addInvocationCompleteEventListener = () => {
|
||||
if (isImageOutput(result) && !nodeDenylist.includes(node.type)) {
|
||||
const { image_name } = result.image;
|
||||
|
||||
if (boardIdToAddTo) {
|
||||
dispatch(
|
||||
imageAddedToBoard({
|
||||
requestBody: {
|
||||
board_id: boardIdToAddTo,
|
||||
image_name,
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// Get its metadata
|
||||
dispatch(
|
||||
imageMetadataReceived({
|
||||
|
@ -25,7 +25,7 @@ type AdditionalBoardsState = {
|
||||
limit: number;
|
||||
total: number;
|
||||
isLoading: boolean;
|
||||
selectedBoardId: EntityId | null;
|
||||
selectedBoardId?: string;
|
||||
searchText?: string;
|
||||
updateBoardModalOpen: boolean;
|
||||
};
|
||||
@ -36,7 +36,6 @@ export const initialBoardsState =
|
||||
limit: 50,
|
||||
total: 0,
|
||||
isLoading: false,
|
||||
selectedBoardId: null,
|
||||
updateBoardModalOpen: false,
|
||||
});
|
||||
|
||||
@ -55,7 +54,7 @@ const boardsSlice = createSlice({
|
||||
boardRemoved: (state, action: PayloadAction<string>) => {
|
||||
boardsAdapter.removeOne(state, action.payload);
|
||||
},
|
||||
boardIdSelected: (state, action: PayloadAction<string | null>) => {
|
||||
boardIdSelected: (state, action: PayloadAction<string | undefined>) => {
|
||||
state.selectedBoardId = action.payload;
|
||||
},
|
||||
setBoardSearchText: (state, action: PayloadAction<string>) => {
|
||||
|
@ -95,6 +95,7 @@ export interface SystemState {
|
||||
shouldAntialiasProgressImage: boolean;
|
||||
language: keyof typeof LANGUAGES;
|
||||
isUploading: boolean;
|
||||
boardIdToAddTo?: string;
|
||||
}
|
||||
|
||||
export const initialSystemState: SystemState = {
|
||||
@ -225,6 +226,7 @@ export const systemSlice = createSlice({
|
||||
*/
|
||||
builder.addCase(appSocketSubscribed, (state, action) => {
|
||||
state.sessionId = action.payload.sessionId;
|
||||
state.boardIdToAddTo = action.payload.boardId;
|
||||
state.canceledSession = '';
|
||||
});
|
||||
|
||||
@ -233,6 +235,7 @@ export const systemSlice = createSlice({
|
||||
*/
|
||||
builder.addCase(appSocketUnsubscribed, (state) => {
|
||||
state.sessionId = null;
|
||||
state.boardIdToAddTo = undefined;
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -53,14 +53,14 @@ export const appSocketDisconnected = createAction<BaseSocketPayload>(
|
||||
* Do not use. Only for use in middleware.
|
||||
*/
|
||||
export const socketSubscribed = createAction<
|
||||
BaseSocketPayload & { sessionId: string }
|
||||
BaseSocketPayload & { sessionId: string; boardId: string | undefined }
|
||||
>('socket/socketSubscribed');
|
||||
|
||||
/**
|
||||
* App-level Socket.IO Subscribed
|
||||
*/
|
||||
export const appSocketSubscribed = createAction<
|
||||
BaseSocketPayload & { sessionId: string }
|
||||
BaseSocketPayload & { sessionId: string; boardId: string | undefined }
|
||||
>('socket/appSocketSubscribed');
|
||||
|
||||
/**
|
||||
|
@ -85,6 +85,7 @@ export const socketMiddleware = () => {
|
||||
socketSubscribed({
|
||||
sessionId: sessionId,
|
||||
timestamp: getTimestamp(),
|
||||
boardId: getState().boards.selectedBoardId,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
|
||||
socketSubscribed({
|
||||
sessionId,
|
||||
timestamp: getTimestamp(),
|
||||
boardId: getState().boards.selectedBoardId,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user