mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
add nanostore for open API schema
This commit is contained in:
parent
55e91b97be
commit
de20711637
@ -10,6 +10,7 @@ import { $customStarUI } from 'app/store/nanostores/customStarUI';
|
||||
import { $galleryHeader } from 'app/store/nanostores/galleryHeader';
|
||||
import { $isDebugging } from 'app/store/nanostores/isDebugging';
|
||||
import { $logo } from 'app/store/nanostores/logo';
|
||||
import { $openAPISchemaUrl } from 'app/store/nanostores/openAPISchemaUrl';
|
||||
import { $projectId } from 'app/store/nanostores/projectId';
|
||||
import { $queueId, DEFAULT_QUEUE_ID } from 'app/store/nanostores/queueId';
|
||||
import { $store } from 'app/store/nanostores/store';
|
||||
@ -28,6 +29,7 @@ const ThemeLocaleProvider = lazy(() => import('./ThemeLocaleProvider'));
|
||||
|
||||
interface Props extends PropsWithChildren {
|
||||
apiUrl?: string;
|
||||
openAPISchemaUrl?: string;
|
||||
token?: string;
|
||||
config?: PartialAppConfig;
|
||||
customNavComponent?: ReactNode;
|
||||
@ -47,6 +49,7 @@ interface Props extends PropsWithChildren {
|
||||
|
||||
const InvokeAIUI = ({
|
||||
apiUrl,
|
||||
openAPISchemaUrl,
|
||||
token,
|
||||
config,
|
||||
customNavComponent,
|
||||
@ -123,6 +126,16 @@ const InvokeAIUI = ({
|
||||
};
|
||||
}, [customNavComponent]);
|
||||
|
||||
useEffect(() => {
|
||||
if (openAPISchemaUrl) {
|
||||
$openAPISchemaUrl.set(openAPISchemaUrl);
|
||||
}
|
||||
|
||||
return () => {
|
||||
$openAPISchemaUrl.set(undefined);
|
||||
};
|
||||
}, [openAPISchemaUrl]);
|
||||
|
||||
useEffect(() => {
|
||||
if (galleryHeader) {
|
||||
$galleryHeader.set(galleryHeader);
|
||||
|
@ -45,7 +45,9 @@ export const useSocketIO = () => {
|
||||
const socketOptions = useMemo(() => {
|
||||
const options: Partial<ManagerOptions & SocketOptions> = {
|
||||
timeout: 60000,
|
||||
path: baseUrl ? '/ws/socket.io' : `${window.location.pathname}ws/socket.io`,
|
||||
path: baseUrl
|
||||
? '/ws/socket.io'
|
||||
: `${window.location.pathname}ws/socket.io`,
|
||||
autoConnect: false, // achtung! removing this breaks the dynamic middleware
|
||||
forceNew: true,
|
||||
};
|
||||
|
@ -0,0 +1,3 @@
|
||||
import { atom } from 'nanostores';
|
||||
|
||||
export const $openAPISchemaUrl = atom<string | undefined>(undefined);
|
@ -1,4 +1,5 @@
|
||||
import { createAsyncThunk } from '@reduxjs/toolkit';
|
||||
import { $openAPISchemaUrl } from 'app/store/nanostores/openAPISchemaUrl';
|
||||
|
||||
function getCircularReplacer() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@ -26,9 +27,12 @@ export const receivedOpenAPISchema = createAsyncThunk(
|
||||
'nodes/receivedOpenAPISchema',
|
||||
async (_, { rejectWithValue }) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${window.location.href.replace(/\/$/, '')}/openapi.json`
|
||||
);
|
||||
const openAPISchemaUrl = $openAPISchemaUrl.get();
|
||||
|
||||
const url = openAPISchemaUrl
|
||||
? openAPISchemaUrl
|
||||
: `${window.location.href.replace(/\/$/, '')}/openapi.json`;
|
||||
const response = await fetch(url);
|
||||
const openAPISchema = await response.json();
|
||||
|
||||
const schemaJSON = JSON.parse(
|
||||
|
Loading…
Reference in New Issue
Block a user