mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): no duplicate network requests on app startup
This commit is contained in:
parent
eb2fcbe28a
commit
8954953eca
@ -4,6 +4,7 @@ import { api } from 'services/api';
|
|||||||
import { receivedOpenAPISchema } from 'services/api/thunks/schema';
|
import { receivedOpenAPISchema } from 'services/api/thunks/schema';
|
||||||
import { appSocketConnected, socketConnected } from 'services/events/actions';
|
import { appSocketConnected, socketConnected } from 'services/events/actions';
|
||||||
import { startAppListening } from '../..';
|
import { startAppListening } from '../..';
|
||||||
|
import { isInitializedChanged } from 'features/system/store/systemSlice';
|
||||||
|
|
||||||
export const addSocketConnectedEventListener = () => {
|
export const addSocketConnectedEventListener = () => {
|
||||||
startAppListening({
|
startAppListening({
|
||||||
@ -13,7 +14,7 @@ export const addSocketConnectedEventListener = () => {
|
|||||||
|
|
||||||
log.debug('Connected');
|
log.debug('Connected');
|
||||||
|
|
||||||
const { nodes, config } = getState();
|
const { nodes, config, system } = getState();
|
||||||
|
|
||||||
const { disabledTabs } = config;
|
const { disabledTabs } = config;
|
||||||
|
|
||||||
@ -21,7 +22,12 @@ export const addSocketConnectedEventListener = () => {
|
|||||||
dispatch(receivedOpenAPISchema());
|
dispatch(receivedOpenAPISchema());
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(api.util.resetApiState());
|
if (system.isInitialized) {
|
||||||
|
// only reset the query caches if this connect event is a *reconnect* event
|
||||||
|
dispatch(api.util.resetApiState());
|
||||||
|
} else {
|
||||||
|
dispatch(isInitializedChanged(true));
|
||||||
|
}
|
||||||
|
|
||||||
// pass along the socket event as an application action
|
// pass along the socket event as an application action
|
||||||
dispatch(appSocketConnected(action.payload));
|
dispatch(appSocketConnected(action.payload));
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { logger } from 'app/logging/logger';
|
import { logger } from 'app/logging/logger';
|
||||||
import { api } from 'services/api';
|
|
||||||
import {
|
import {
|
||||||
appSocketDisconnected,
|
appSocketDisconnected,
|
||||||
socketDisconnected,
|
socketDisconnected,
|
||||||
@ -13,8 +12,6 @@ export const addSocketDisconnectedEventListener = () => {
|
|||||||
const log = logger('socketio');
|
const log = logger('socketio');
|
||||||
log.debug('Disconnected');
|
log.debug('Disconnected');
|
||||||
|
|
||||||
dispatch(api.util.resetApiState());
|
|
||||||
|
|
||||||
// pass along the socket event as an application action
|
// pass along the socket event as an application action
|
||||||
dispatch(appSocketDisconnected(action.payload));
|
dispatch(appSocketDisconnected(action.payload));
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { SystemState } from './types';
|
import { SystemState } from './types';
|
||||||
|
|
||||||
export const systemPersistDenylist: (keyof SystemState)[] = [
|
export const systemPersistDenylist: (keyof SystemState)[] = [
|
||||||
|
'isInitialized',
|
||||||
'isConnected',
|
'isConnected',
|
||||||
'denoiseProgress',
|
'denoiseProgress',
|
||||||
'status',
|
'status',
|
||||||
|
@ -24,6 +24,7 @@ import { SystemState, LANGUAGES } from './types';
|
|||||||
import { zPydanticValidationError } from './zodSchemas';
|
import { zPydanticValidationError } from './zodSchemas';
|
||||||
|
|
||||||
export const initialSystemState: SystemState = {
|
export const initialSystemState: SystemState = {
|
||||||
|
isInitialized: false,
|
||||||
isConnected: false,
|
isConnected: false,
|
||||||
shouldConfirmOnDelete: true,
|
shouldConfirmOnDelete: true,
|
||||||
enableImageDebugging: false,
|
enableImageDebugging: false,
|
||||||
@ -82,6 +83,9 @@ export const systemSlice = createSlice({
|
|||||||
) {
|
) {
|
||||||
state.shouldEnableInformationalPopovers = action.payload;
|
state.shouldEnableInformationalPopovers = action.payload;
|
||||||
},
|
},
|
||||||
|
isInitializedChanged(state, action: PayloadAction<boolean>) {
|
||||||
|
state.isInitialized = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
extraReducers(builder) {
|
extraReducers(builder) {
|
||||||
/**
|
/**
|
||||||
@ -242,6 +246,7 @@ export const {
|
|||||||
shouldUseNSFWCheckerChanged,
|
shouldUseNSFWCheckerChanged,
|
||||||
shouldUseWatermarkerChanged,
|
shouldUseWatermarkerChanged,
|
||||||
setShouldEnableInformationalPopovers,
|
setShouldEnableInformationalPopovers,
|
||||||
|
isInitializedChanged,
|
||||||
} = systemSlice.actions;
|
} = systemSlice.actions;
|
||||||
|
|
||||||
export default systemSlice.reducer;
|
export default systemSlice.reducer;
|
||||||
|
@ -21,6 +21,7 @@ export type DenoiseProgress = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export interface SystemState {
|
export interface SystemState {
|
||||||
|
isInitialized: boolean;
|
||||||
isConnected: boolean;
|
isConnected: boolean;
|
||||||
shouldConfirmOnDelete: boolean;
|
shouldConfirmOnDelete: boolean;
|
||||||
enableImageDebugging: boolean;
|
enableImageDebugging: boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user