mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): update linear UI to use new board field on save_image
- No longer need to make network request to add image to board after it's finished - removed - Update linear graphs & upscale graph to save image to the board - Update autoSwitch logic so when image is generated we still switch to the right board
This commit is contained in:
parent
43fbac26df
commit
88c8cb61f0
@ -37,6 +37,7 @@ export const addInvocationCompleteEventListener = () => {
|
|||||||
const { image_name } = result.image;
|
const { image_name } = result.image;
|
||||||
const { canvas, gallery } = getState();
|
const { canvas, gallery } = getState();
|
||||||
|
|
||||||
|
// This populates the `getImageDTO` cache
|
||||||
const imageDTO = await dispatch(
|
const imageDTO = await dispatch(
|
||||||
imagesApi.endpoints.getImageDTO.initiate(image_name)
|
imagesApi.endpoints.getImageDTO.initiate(image_name)
|
||||||
).unwrap();
|
).unwrap();
|
||||||
@ -52,27 +53,14 @@ export const addInvocationCompleteEventListener = () => {
|
|||||||
if (!imageDTO.is_intermediate) {
|
if (!imageDTO.is_intermediate) {
|
||||||
/**
|
/**
|
||||||
* Cache updates for when an image result is received
|
* Cache updates for when an image result is received
|
||||||
* - *add* to getImageDTO
|
* - add it to the no_board/images
|
||||||
* - IF `autoAddBoardId` is set:
|
|
||||||
* - THEN add it to the board_id/images
|
|
||||||
* - ELSE (`autoAddBoardId` is not set):
|
|
||||||
* - THEN add it to the no_board/images
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { autoAddBoardId } = gallery;
|
|
||||||
if (autoAddBoardId && autoAddBoardId !== 'none') {
|
|
||||||
dispatch(
|
|
||||||
imagesApi.endpoints.addImageToBoard.initiate({
|
|
||||||
board_id: autoAddBoardId,
|
|
||||||
imageDTO,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
dispatch(
|
dispatch(
|
||||||
imagesApi.util.updateQueryData(
|
imagesApi.util.updateQueryData(
|
||||||
'listImages',
|
'listImages',
|
||||||
{
|
{
|
||||||
board_id: 'none',
|
board_id: imageDTO.board_id ?? 'none',
|
||||||
categories: IMAGE_CATEGORIES,
|
categories: IMAGE_CATEGORIES,
|
||||||
},
|
},
|
||||||
(draft) => {
|
(draft) => {
|
||||||
@ -80,26 +68,21 @@ export const addInvocationCompleteEventListener = () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
imagesApi.util.invalidateTags([
|
imagesApi.util.invalidateTags([
|
||||||
{ type: 'BoardImagesTotal', id: autoAddBoardId },
|
{ type: 'BoardImagesTotal', id: imageDTO.board_id },
|
||||||
{ type: 'BoardAssetsTotal', id: autoAddBoardId },
|
{ type: 'BoardAssetsTotal', id: imageDTO.board_id },
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
const { selectedBoardId, shouldAutoSwitch } = gallery;
|
const { shouldAutoSwitch } = gallery;
|
||||||
|
|
||||||
// If auto-switch is enabled, select the new image
|
// If auto-switch is enabled, select the new image
|
||||||
if (shouldAutoSwitch) {
|
if (shouldAutoSwitch) {
|
||||||
// if auto-add is enabled, switch the board as the image comes in
|
// if auto-add is enabled, switch the board as the image comes in
|
||||||
if (autoAddBoardId && autoAddBoardId !== selectedBoardId) {
|
|
||||||
dispatch(boardIdSelected(autoAddBoardId));
|
|
||||||
dispatch(galleryViewChanged('images'));
|
dispatch(galleryViewChanged('images'));
|
||||||
} else if (!autoAddBoardId) {
|
dispatch(boardIdSelected(imageDTO.board_id ?? 'none'));
|
||||||
dispatch(galleryViewChanged('images'));
|
|
||||||
}
|
|
||||||
dispatch(imageSelected(imageDTO));
|
dispatch(imageSelected(imageDTO));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,14 @@ export const addUpscaleRequestedListener = () => {
|
|||||||
const log = logger('session');
|
const log = logger('session');
|
||||||
|
|
||||||
const { image_name } = action.payload;
|
const { image_name } = action.payload;
|
||||||
const { esrganModelName } = getState().postprocessing;
|
const state = getState();
|
||||||
|
const { esrganModelName } = state.postprocessing;
|
||||||
|
const { autoAddBoardId } = state.gallery;
|
||||||
|
|
||||||
const graph = buildAdHocUpscaleGraph({
|
const graph = buildAdHocUpscaleGraph({
|
||||||
image_name,
|
image_name,
|
||||||
esrganModelName,
|
esrganModelName,
|
||||||
|
autoAddBoardId,
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -24,12 +24,14 @@ export const addSaveImageNode = (
|
|||||||
const activeTabName = activeTabNameSelector(state);
|
const activeTabName = activeTabNameSelector(state);
|
||||||
const is_intermediate =
|
const is_intermediate =
|
||||||
activeTabName === 'unifiedCanvas' ? !state.canvas.shouldAutoSave : false;
|
activeTabName === 'unifiedCanvas' ? !state.canvas.shouldAutoSave : false;
|
||||||
|
const { autoAddBoardId } = state.gallery;
|
||||||
|
|
||||||
const saveImageNode: SaveImageInvocation = {
|
const saveImageNode: SaveImageInvocation = {
|
||||||
id: SAVE_IMAGE,
|
id: SAVE_IMAGE,
|
||||||
type: 'save_image',
|
type: 'save_image',
|
||||||
is_intermediate,
|
is_intermediate,
|
||||||
use_cache: false,
|
use_cache: false,
|
||||||
|
board: autoAddBoardId === 'none' ? undefined : { board_id: autoAddBoardId },
|
||||||
};
|
};
|
||||||
|
|
||||||
graph.nodes[SAVE_IMAGE] = saveImageNode;
|
graph.nodes[SAVE_IMAGE] = saveImageNode;
|
||||||
|
@ -6,15 +6,18 @@ import {
|
|||||||
SaveImageInvocation,
|
SaveImageInvocation,
|
||||||
} from 'services/api/types';
|
} from 'services/api/types';
|
||||||
import { REALESRGAN as ESRGAN, SAVE_IMAGE } from './constants';
|
import { REALESRGAN as ESRGAN, SAVE_IMAGE } from './constants';
|
||||||
|
import { BoardId } from 'features/gallery/store/types';
|
||||||
|
|
||||||
type Arg = {
|
type Arg = {
|
||||||
image_name: string;
|
image_name: string;
|
||||||
esrganModelName: ESRGANModelName;
|
esrganModelName: ESRGANModelName;
|
||||||
|
autoAddBoardId: BoardId;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const buildAdHocUpscaleGraph = ({
|
export const buildAdHocUpscaleGraph = ({
|
||||||
image_name,
|
image_name,
|
||||||
esrganModelName,
|
esrganModelName,
|
||||||
|
autoAddBoardId,
|
||||||
}: Arg): Graph => {
|
}: Arg): Graph => {
|
||||||
const realesrganNode: ESRGANInvocation = {
|
const realesrganNode: ESRGANInvocation = {
|
||||||
id: ESRGAN,
|
id: ESRGAN,
|
||||||
@ -28,6 +31,8 @@ export const buildAdHocUpscaleGraph = ({
|
|||||||
id: SAVE_IMAGE,
|
id: SAVE_IMAGE,
|
||||||
type: 'save_image',
|
type: 'save_image',
|
||||||
use_cache: false,
|
use_cache: false,
|
||||||
|
is_intermediate: false,
|
||||||
|
board: autoAddBoardId === 'none' ? undefined : { board_id: autoAddBoardId },
|
||||||
};
|
};
|
||||||
|
|
||||||
const graph: NonNullableGraph = {
|
const graph: NonNullableGraph = {
|
||||||
|
Loading…
Reference in New Issue
Block a user