feat(ui): add support for shouldFetchImages if UI needs to re-fetch an image URL

This commit is contained in:
Mary Hipp
2023-04-22 14:01:55 -04:00
committed by psychedelicious
parent f0e4a2124a
commit 9f8ff912c4
6 changed files with 88 additions and 5 deletions

View File

@ -30,6 +30,8 @@ import {
import { OpenAPI } from 'services/api';
import { receivedModels } from 'services/thunks/model';
import { receivedOpenAPISchema } from 'services/thunks/schema';
import { isImageOutput } from 'services/types/guards';
import { imageReceived, thumbnailReceived } from 'services/thunks/image';
export const socketMiddleware = () => {
let areListenersSet = false;
@ -213,6 +215,21 @@ export const socketMiddleware = () => {
dispatch(sessionInvoked({ sessionId }));
}
if (invocationComplete.match(action)) {
const { results } = getState();
if (results.shouldFetchImages) {
const { result } = action.payload.data;
if (isImageOutput(result)) {
const imageName = result.image.image_name;
const imageType = result.image.image_type;
dispatch(imageReceived({ imageName, imageType }));
dispatch(thumbnailReceived({ imageName, imageType }));
}
}
}
// Always pass the action on so other middleware and reducers can handle it
next(action);
};