mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): fix middleware types
This commit is contained in:
parent
f9c243d29f
commit
4ac447cf74
@ -1,4 +1,4 @@
|
|||||||
import { AnyAction, Dispatch, MiddlewareAPI } from '@reduxjs/toolkit';
|
import { MiddlewareAPI } from '@reduxjs/toolkit';
|
||||||
import dateFormat from 'dateformat';
|
import dateFormat from 'dateformat';
|
||||||
import i18n from 'i18n';
|
import i18n from 'i18n';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
@ -18,7 +18,7 @@ import {
|
|||||||
setIntermediateImage,
|
setIntermediateImage,
|
||||||
} from 'features/gallery/store/gallerySlice';
|
} from 'features/gallery/store/gallerySlice';
|
||||||
|
|
||||||
import type { RootState } from 'app/store';
|
import type { AppDispatch, RootState } from 'app/store';
|
||||||
import {
|
import {
|
||||||
GeneratorProgressEvent,
|
GeneratorProgressEvent,
|
||||||
InvocationCompleteEvent,
|
InvocationCompleteEvent,
|
||||||
@ -33,12 +33,13 @@ import {
|
|||||||
STATUS,
|
STATUS,
|
||||||
} from 'services/apiSlice';
|
} from 'services/apiSlice';
|
||||||
import { emitUnsubscribe } from './actions';
|
import { emitUnsubscribe } from './actions';
|
||||||
|
import { listSessions } from 'services/thunks/session';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an object containing listener callbacks
|
* Returns an object containing listener callbacks
|
||||||
*/
|
*/
|
||||||
const makeSocketIOListeners = (
|
const makeSocketIOListeners = (
|
||||||
store: MiddlewareAPI<Dispatch<AnyAction>, RootState>
|
store: MiddlewareAPI<AppDispatch, RootState>
|
||||||
) => {
|
) => {
|
||||||
const { dispatch, getState } = store;
|
const { dispatch, getState } = store;
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import { Middleware } from '@reduxjs/toolkit';
|
import { Middleware, MiddlewareAPI } from '@reduxjs/toolkit';
|
||||||
import { emitSubscribe } from 'app/nodesSocketio/actions';
|
import { emitSubscribe } from 'app/nodesSocketio/actions';
|
||||||
|
import { AppDispatch, RootState } from 'app/store';
|
||||||
import { setSessionId } from './apiSlice';
|
import { setSessionId } from './apiSlice';
|
||||||
import { invokeSession } from './thunks/session';
|
import { invokeSession } from './thunks/session';
|
||||||
|
|
||||||
export const invokeMiddleware: Middleware = (store) => (next) => (action) => {
|
export const invokeMiddleware: Middleware =
|
||||||
|
(store: MiddlewareAPI<AppDispatch, RootState>) => (next) => (action) => {
|
||||||
const { dispatch } = store;
|
const { dispatch } = store;
|
||||||
|
|
||||||
if (action.type === 'api/createSession/fulfilled' && action?.payload?.id) {
|
if (action.type === 'api/createSession/fulfilled' && action?.payload?.id) {
|
||||||
@ -12,9 +14,8 @@ export const invokeMiddleware: Middleware = (store) => (next) => (action) => {
|
|||||||
|
|
||||||
dispatch(setSessionId(sessionId));
|
dispatch(setSessionId(sessionId));
|
||||||
dispatch(emitSubscribe(sessionId));
|
dispatch(emitSubscribe(sessionId));
|
||||||
// types are wrong but this works
|
|
||||||
dispatch(invokeSession({ sessionId }));
|
dispatch(invokeSession({ sessionId }));
|
||||||
} else {
|
} else {
|
||||||
next(action);
|
next(action);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user