mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add POC image record fetching
This commit is contained in:
parent
3f94f81acd
commit
4e29a751d8
@ -6,7 +6,12 @@ import {
|
||||
} from 'services/util/deserializeImageField';
|
||||
import { Image } from 'app/types/invokeai';
|
||||
import { resultAdded } from 'features/gallery/store/resultsSlice';
|
||||
import { imageReceived, thumbnailReceived } from 'services/thunks/image';
|
||||
import {
|
||||
imageReceived,
|
||||
imageRecordReceived,
|
||||
imageUrlsReceived,
|
||||
thumbnailReceived,
|
||||
} from 'services/thunks/image';
|
||||
import { startAppListening } from '..';
|
||||
import { imageSelected } from 'features/gallery/store/gallerySlice';
|
||||
import { addImageToStagingArea } from 'features/canvas/store/canvasSlice';
|
||||
@ -24,7 +29,7 @@ export const addImageResultReceivedListener = () => {
|
||||
}
|
||||
return false;
|
||||
},
|
||||
effect: (action, { getState, dispatch }) => {
|
||||
effect: async (action, { getState, dispatch, take }) => {
|
||||
if (!invocationComplete.match(action)) {
|
||||
return;
|
||||
}
|
||||
@ -35,6 +40,29 @@ export const addImageResultReceivedListener = () => {
|
||||
if (isImageOutput(result) && !nodeDenylist.includes(node.type)) {
|
||||
const name = result.image.image_name;
|
||||
const type = result.image.image_type;
|
||||
|
||||
dispatch(imageUrlsReceived({ imageName: name, imageType: type }));
|
||||
|
||||
const [{ payload }] = await take(
|
||||
(action): action is ReturnType<typeof imageUrlsReceived.fulfilled> =>
|
||||
imageUrlsReceived.fulfilled.match(action) &&
|
||||
action.payload.image_name === name
|
||||
);
|
||||
|
||||
console.log(payload);
|
||||
|
||||
dispatch(imageRecordReceived({ imageName: name, imageType: type }));
|
||||
|
||||
const [x] = await take(
|
||||
(
|
||||
action
|
||||
): action is ReturnType<typeof imageRecordReceived.fulfilled> =>
|
||||
imageRecordReceived.fulfilled.match(action) &&
|
||||
action.payload.image_name === name
|
||||
);
|
||||
|
||||
console.log(x);
|
||||
|
||||
const state = getState();
|
||||
|
||||
// if we need to refetch, set URLs to placeholder for now
|
||||
|
@ -6,6 +6,38 @@ import { getHeaders } from 'services/util/getHeaders';
|
||||
|
||||
const imagesLog = log.child({ namespace: 'image' });
|
||||
|
||||
type imageUrlsReceivedArg = Parameters<
|
||||
(typeof ImagesService)['getImageUrls']
|
||||
>[0];
|
||||
|
||||
/**
|
||||
* `ImagesService.getImageUrls()` thunk
|
||||
*/
|
||||
export const imageUrlsReceived = createAppAsyncThunk(
|
||||
'api/imageUrlsReceived',
|
||||
async (arg: imageUrlsReceivedArg) => {
|
||||
const response = await ImagesService.getImageUrls(arg);
|
||||
imagesLog.info({ arg, response }, 'Received image urls');
|
||||
return response;
|
||||
}
|
||||
);
|
||||
|
||||
type imageRecordReceivedArg = Parameters<
|
||||
(typeof ImagesService)['getImageUrls']
|
||||
>[0];
|
||||
|
||||
/**
|
||||
* `ImagesService.getImageUrls()` thunk
|
||||
*/
|
||||
export const imageRecordReceived = createAppAsyncThunk(
|
||||
'api/imageUrlsReceived',
|
||||
async (arg: imageRecordReceivedArg) => {
|
||||
const response = await ImagesService.getImageRecord(arg);
|
||||
imagesLog.info({ arg, response }, 'Received image record');
|
||||
return response;
|
||||
}
|
||||
);
|
||||
|
||||
type ImageReceivedArg = Parameters<(typeof ImagesService)['getImage']>[0];
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user