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